Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 7 |
CRAP | |
0.00% |
0 / 1 |
| TaintednessWithError | |
0.00% |
0 / 27 |
|
0.00% |
0 / 7 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| emptySingleton | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| unknownSingleton | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| getTaintedness | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getError | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getMethodLinks | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| asMergedWith | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php declare( strict_types=1 ); |
| 2 | |
| 3 | namespace SecurityCheckPlugin; |
| 4 | |
| 5 | /** |
| 6 | * Object that encapsulates a Taintedness and a list of lines that caused it |
| 7 | */ |
| 8 | class TaintednessWithError { |
| 9 | /** @var Taintedness */ |
| 10 | private $taintedness; |
| 11 | /** |
| 12 | * @var CausedByLines |
| 13 | */ |
| 14 | private $error; |
| 15 | |
| 16 | /** @var MethodLinks */ |
| 17 | private $methodLinks; |
| 18 | |
| 19 | public function __construct( Taintedness $taintedness, CausedByLines $error, MethodLinks $methodLinks ) { |
| 20 | $this->taintedness = $taintedness; |
| 21 | $this->error = $error; |
| 22 | $this->methodLinks = $methodLinks; |
| 23 | } |
| 24 | |
| 25 | public static function emptySingleton(): self { |
| 26 | static $singleton; |
| 27 | if ( !$singleton ) { |
| 28 | $singleton = new self( |
| 29 | Taintedness::safeSingleton(), |
| 30 | CausedByLines::emptySingleton(), |
| 31 | MethodLinks::emptySingleton() |
| 32 | ); |
| 33 | } |
| 34 | return $singleton; |
| 35 | } |
| 36 | |
| 37 | public static function unknownSingleton(): self { |
| 38 | static $singleton; |
| 39 | if ( !$singleton ) { |
| 40 | $singleton = new self( |
| 41 | Taintedness::unknownSingleton(), |
| 42 | CausedByLines::emptySingleton(), |
| 43 | MethodLinks::emptySingleton() |
| 44 | ); |
| 45 | } |
| 46 | return $singleton; |
| 47 | } |
| 48 | |
| 49 | public function getTaintedness(): Taintedness { |
| 50 | return $this->taintedness; |
| 51 | } |
| 52 | |
| 53 | public function getError(): CausedByLines { |
| 54 | return $this->error; |
| 55 | } |
| 56 | |
| 57 | public function getMethodLinks(): MethodLinks { |
| 58 | return $this->methodLinks; |
| 59 | } |
| 60 | |
| 61 | public function asMergedWith( self $other ): self { |
| 62 | $ret = clone $this; |
| 63 | $ret->taintedness = $ret->taintedness->asMergedWith( $other->taintedness ); |
| 64 | $ret->error = $ret->error->asMergedWith( $other->error ); |
| 65 | $ret->methodLinks = $ret->methodLinks->asMergedWith( $other->methodLinks ); |
| 66 | return $ret; |
| 67 | } |
| 68 | } |