1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This code is licensed under the BSD 3-Clause License. |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2017, Maks Rafalko |
6
|
|
|
* All rights reserved. |
7
|
|
|
* |
8
|
|
|
* Redistribution and use in source and binary forms, with or without |
9
|
|
|
* modification, are permitted provided that the following conditions are met: |
10
|
|
|
* |
11
|
|
|
* * Redistributions of source code must retain the above copyright notice, this |
12
|
|
|
* list of conditions and the following disclaimer. |
13
|
|
|
* |
14
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice, |
15
|
|
|
* this list of conditions and the following disclaimer in the documentation |
16
|
|
|
* and/or other materials provided with the distribution. |
17
|
|
|
* |
18
|
|
|
* * Neither the name of the copyright holder nor the names of its |
19
|
|
|
* contributors may be used to endorse or promote products derived from |
20
|
|
|
* this software without specific prior written permission. |
21
|
|
|
* |
22
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
23
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
25
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
26
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
28
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
29
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
30
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
31
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
32
|
|
|
*/ |
33
|
|
|
|
34
|
|
|
declare(strict_types=1); |
35
|
|
|
|
36
|
|
|
namespace Infection\Mutant; |
37
|
|
|
|
38
|
|
|
use Infection\AbstractTestFramework\Coverage\TestLocation; |
39
|
|
|
use Infection\Mutation\Mutation; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @internal |
43
|
|
|
* @final |
44
|
|
|
*/ |
45
|
|
|
class Mutant |
46
|
|
|
{ |
47
|
|
|
private $mutantFilePath; |
48
|
|
|
private $mutation; |
49
|
|
|
private $mutatedCode; |
50
|
|
|
private $diff; |
51
|
|
|
private $prettyPrintedOriginalCode; |
52
|
|
|
|
53
|
|
|
public function __construct( |
54
|
|
|
string $mutantFilePath, |
55
|
|
|
Mutation $mutation, |
56
|
|
|
string $mutatedCode, |
57
|
|
|
string $diff, |
58
|
|
|
string $prettyPrintedOriginalCode |
59
|
|
|
) { |
60
|
|
|
$this->mutantFilePath = $mutantFilePath; |
61
|
|
|
$this->mutation = $mutation; |
62
|
|
|
$this->mutatedCode = $mutatedCode; |
63
|
|
|
$this->diff = $diff; |
64
|
|
|
$this->prettyPrintedOriginalCode = $prettyPrintedOriginalCode; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getFilePath(): string |
68
|
|
|
{ |
69
|
|
|
return $this->mutantFilePath; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getMutation(): Mutation |
73
|
|
|
{ |
74
|
|
|
return $this->mutation; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getMutatedCode(): string |
78
|
|
|
{ |
79
|
|
|
return $this->mutatedCode; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function getPrettyPrintedOriginalCode(): string |
83
|
|
|
{ |
84
|
|
|
return $this->prettyPrintedOriginalCode; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function getDiff(): string |
88
|
|
|
{ |
89
|
|
|
return $this->diff; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function isCoveredByTest(): bool |
93
|
|
|
{ |
94
|
|
|
return $this->mutation->isCoveredByTest(); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return TestLocation[] |
99
|
|
|
*/ |
100
|
|
|
public function getTests(): array |
101
|
|
|
{ |
102
|
|
|
return $this->mutation->getAllTests(); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|