Skip to content

Commit f50cdae

Browse files
committed
Add method stubs for Node objects
1 parent 67c1d8c commit f50cdae

File tree

2 files changed

+202
-0
lines changed

2 files changed

+202
-0
lines changed

src/Node/Directory.php

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ final class Directory extends AbstractNode implements \IteratorAggregate
5151
*/
5252
private $linesOfCode;
5353

54+
/**
55+
* @var array
56+
*/
57+
private $paths;
58+
59+
/**
60+
* @var array
61+
*/
62+
private $branches;
63+
5464
/**
5565
* @var int
5666
*/
@@ -106,6 +116,26 @@ final class Directory extends AbstractNode implements \IteratorAggregate
106116
*/
107117
private $numTestedFunctions = -1;
108118

119+
/**
120+
* @var int
121+
*/
122+
private $numPaths = -1;
123+
124+
/**
125+
* @var int
126+
*/
127+
private $numTestedPaths = -1;
128+
129+
/**
130+
* @var int
131+
*/
132+
private $numBranches = -1;
133+
134+
/**
135+
* @var int
136+
*/
137+
private $numTestedBranches = -1;
138+
109139
/**
110140
* Returns the number of files in/under this node.
111141
*/
@@ -160,6 +190,8 @@ public function addFile(string $name, array $coverageData, array $testData, bool
160190

161191
$this->numExecutableLines = -1;
162192
$this->numExecutedLines = -1;
193+
$this->numPaths = -1;
194+
$this->numTestedPaths = -1;
163195

164196
return $file;
165197
}
@@ -424,4 +456,106 @@ public function getNumTestedFunctions(): int
424456

425457
return $this->numTestedFunctions;
426458
}
459+
460+
/**
461+
* Returns the paths of this node.
462+
*/
463+
public function getPaths(): array
464+
{
465+
if ($this->paths === null) {
466+
$this->paths = [];
467+
468+
foreach ($this->children as $child) {
469+
$this->paths = \array_merge(
470+
$this->paths,
471+
$child->getPaths()
472+
);
473+
}
474+
}
475+
476+
return $this->paths;
477+
}
478+
479+
/**
480+
* Returns the branches of this node.
481+
*/
482+
public function getBranches(): array
483+
{
484+
if ($this->branches === null) {
485+
$this->branches = [];
486+
487+
foreach ($this->children as $child) {
488+
$this->branches = \array_merge(
489+
$this->branches,
490+
$child->getBranches()
491+
);
492+
}
493+
}
494+
495+
return $this->branches;
496+
}
497+
498+
/**
499+
* Returns the number of paths.
500+
*/
501+
public function getNumPaths(): int
502+
{
503+
if ($this->numPaths === -1) {
504+
$this->numPaths = 0;
505+
506+
foreach ($this->children as $child) {
507+
$this->numMethods += $child->getNumPaths();
508+
}
509+
}
510+
511+
return $this->numPaths;
512+
}
513+
514+
/**
515+
* Returns the number of tested paths.
516+
*/
517+
public function getNumTestedPaths(): int
518+
{
519+
if ($this->numTestedPaths === -1) {
520+
$this->numTestedPaths = 0;
521+
522+
foreach ($this->children as $child) {
523+
$this->numTestedPaths += $child->getNumTestedPaths();
524+
}
525+
}
526+
527+
return $this->numTestedPaths;
528+
}
529+
530+
/**
531+
* Returns the number of branches.
532+
*/
533+
public function getNumBranches(): int
534+
{
535+
if ($this->numBranches === -1) {
536+
$this->numBranches = 0;
537+
538+
foreach ($this->children as $child) {
539+
$this->numBranches += $child->getNumBranches();
540+
}
541+
}
542+
543+
return $this->numBranches;
544+
}
545+
546+
/**
547+
* Returns the number of tested branches.
548+
*/
549+
public function getNumTestedBranches(): int
550+
{
551+
if ($this->numTestedBranches === -1) {
552+
$this->numTestedBranches = 0;
553+
554+
foreach ($this->children as $child) {
555+
$this->numTestedBranches += $child->getNumTestedBranches();
556+
}
557+
}
558+
559+
return $this->numTestedBranches;
560+
}
427561
}

src/Node/File.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,26 @@ final class File extends AbstractNode
8989
*/
9090
private $numTestedFunctions;
9191

92+
/**
93+
* @var int
94+
*/
95+
private $numPaths = 0;
96+
97+
/**
98+
* @var int
99+
*/
100+
private $numTestedPaths = 0;
101+
102+
/**
103+
* @var int
104+
*/
105+
private $numBranches = 0;
106+
107+
/**
108+
* @var int
109+
*/
110+
private $numTestedBranches = 0;
111+
92112
/**
93113
* @var bool
94114
*/
@@ -608,4 +628,52 @@ private function newMethod(string $methodName, array $method, string $link): arr
608628
'link' => $link . $method['startLine'],
609629
];
610630
}
631+
632+
/**
633+
* Returns the paths of this node.
634+
*/
635+
public function getPaths(): array
636+
{
637+
// TODO: Implement getPaths() method.
638+
}
639+
640+
/**
641+
* Returns the branches of this node.
642+
*/
643+
public function getBranches(): array
644+
{
645+
// TODO: Implement getBranches() method.
646+
}
647+
648+
/**
649+
* Returns the number of paths.
650+
*/
651+
public function getNumPaths(): int
652+
{
653+
// TODO: Implement getNumPaths() method.
654+
}
655+
656+
/**
657+
* Returns the number of tested paths.
658+
*/
659+
public function getNumTestedPaths(): int
660+
{
661+
// TODO: Implement getNumTestedPaths() method.
662+
}
663+
664+
/**
665+
* Returns the number of branches.
666+
*/
667+
public function getNumBranches(): int
668+
{
669+
// TODO: Implement getNumBranches() method.
670+
}
671+
672+
/**
673+
* Returns the number of tested branches.
674+
*/
675+
public function getNumTestedBranches(): int
676+
{
677+
// TODO: Implement getNumTestedBranches() method.
678+
}
611679
}

0 commit comments

Comments
 (0)