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