|
23 | 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
24 | 24 | * SOFTWARE. |
25 | 25 | */ |
26 | | -declare(strict_types = 1); |
| 26 | +declare(strict_types=1); |
27 | 27 |
|
28 | 28 | namespace CodeLts\CliTools; |
29 | 29 |
|
|
32 | 32 | class AnalysisResult |
33 | 33 | { |
34 | 34 |
|
35 | | - /** @var \CodeLts\CliTools\Error[] sorted by their file name, line number and message */ |
36 | | - private $fileSpecificErrors; |
37 | | - |
38 | | - /** @var string[] */ |
39 | | - private $notFileSpecificErrors; |
40 | | - |
41 | | - /** @var string[] */ |
42 | | - private $internalErrors; |
43 | | - |
44 | | - /** @var string[] */ |
45 | | - private $warnings; |
46 | | - |
47 | | - /** |
48 | | - * @param \CodeLts\CliTools\Error[] $fileSpecificErrors |
49 | | - * @param string[] $notFileSpecificErrors |
50 | | - * @param string[] $internalErrors |
51 | | - * @param string[] $warnings |
52 | | - */ |
53 | | - public function __construct( |
54 | | - array $fileSpecificErrors, |
55 | | - array $notFileSpecificErrors, |
56 | | - array $internalErrors, |
57 | | - array $warnings |
58 | | - ) |
59 | | - { |
60 | | - usort( |
61 | | - $fileSpecificErrors, |
62 | | - static function (Error $a, Error $b): int { |
63 | | - return [ |
64 | | - $a->getFile(), |
65 | | - $a->getLine(), |
66 | | - $a->getMessage(), |
67 | | - ] <=> [ |
68 | | - $b->getFile(), |
69 | | - $b->getLine(), |
70 | | - $b->getMessage(), |
71 | | - ]; |
72 | | - } |
73 | | - ); |
74 | | - |
75 | | - $this->fileSpecificErrors = $fileSpecificErrors; |
76 | | - $this->notFileSpecificErrors = $notFileSpecificErrors; |
77 | | - $this->internalErrors = $internalErrors; |
78 | | - $this->warnings = $warnings; |
79 | | - } |
80 | | - |
81 | | - public function hasErrors(): bool |
82 | | - { |
83 | | - return $this->getTotalErrorsCount() > 0; |
84 | | - } |
85 | | - |
86 | | - public function getTotalErrorsCount(): int |
87 | | - { |
88 | | - return count($this->fileSpecificErrors) + count($this->notFileSpecificErrors); |
89 | | - } |
90 | | - |
91 | | - /** |
92 | | - * @return \CodeLts\CliTools\Error[] sorted by their file name, line number and message |
93 | | - */ |
94 | | - public function getFileSpecificErrors(): array |
95 | | - { |
96 | | - return $this->fileSpecificErrors; |
97 | | - } |
98 | | - |
99 | | - /** |
100 | | - * @return string[] |
101 | | - */ |
102 | | - public function getNotFileSpecificErrors(): array |
103 | | - { |
104 | | - return $this->notFileSpecificErrors; |
105 | | - } |
106 | | - |
107 | | - /** |
108 | | - * @return string[] |
109 | | - */ |
110 | | - public function getInternalErrors(): array |
111 | | - { |
112 | | - return $this->internalErrors; |
113 | | - } |
114 | | - |
115 | | - /** |
116 | | - * @return string[] |
117 | | - */ |
118 | | - public function getWarnings(): array |
119 | | - { |
120 | | - return $this->warnings; |
121 | | - } |
122 | | - |
123 | | - public function hasWarnings(): bool |
124 | | - { |
125 | | - return count($this->warnings) > 0; |
126 | | - } |
127 | | - |
128 | | - public function hasInternalErrors(): bool |
129 | | - { |
130 | | - return count($this->internalErrors) > 0; |
131 | | - } |
132 | | - |
| 35 | + /** @var \CodeLts\CliTools\Error[] sorted by their file name, line number and message */ |
| 36 | + private $fileSpecificErrors; |
| 37 | + |
| 38 | + /** @var string[] */ |
| 39 | + private $notFileSpecificErrors; |
| 40 | + |
| 41 | + /** @var string[] */ |
| 42 | + private $internalErrors; |
| 43 | + |
| 44 | + /** @var string[] */ |
| 45 | + private $warnings; |
| 46 | + |
| 47 | + /** |
| 48 | + * @param \CodeLts\CliTools\Error[] $fileSpecificErrors |
| 49 | + * @param string[] $notFileSpecificErrors |
| 50 | + * @param string[] $internalErrors |
| 51 | + * @param string[] $warnings |
| 52 | + */ |
| 53 | + public function __construct( |
| 54 | + array $fileSpecificErrors, |
| 55 | + array $notFileSpecificErrors, |
| 56 | + array $internalErrors, |
| 57 | + array $warnings |
| 58 | + ) { |
| 59 | + usort( |
| 60 | + $fileSpecificErrors, |
| 61 | + static function (Error $a, Error $b): int { |
| 62 | + return [ |
| 63 | + $a->getFile(), |
| 64 | + $a->getLine(), |
| 65 | + $a->getMessage(), |
| 66 | + ] <=> [ |
| 67 | + $b->getFile(), |
| 68 | + $b->getLine(), |
| 69 | + $b->getMessage(), |
| 70 | + ]; |
| 71 | + } |
| 72 | + ); |
| 73 | + |
| 74 | + $this->fileSpecificErrors = $fileSpecificErrors; |
| 75 | + $this->notFileSpecificErrors = $notFileSpecificErrors; |
| 76 | + $this->internalErrors = $internalErrors; |
| 77 | + $this->warnings = $warnings; |
| 78 | + } |
| 79 | + |
| 80 | + public function hasErrors(): bool |
| 81 | + { |
| 82 | + return $this->getTotalErrorsCount() > 0; |
| 83 | + } |
| 84 | + |
| 85 | + public function getTotalErrorsCount(): int |
| 86 | + { |
| 87 | + return count($this->fileSpecificErrors) + count($this->notFileSpecificErrors); |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * @return \CodeLts\CliTools\Error[] sorted by their file name, line number and message |
| 92 | + */ |
| 93 | + public function getFileSpecificErrors(): array |
| 94 | + { |
| 95 | + return $this->fileSpecificErrors; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * @return string[] |
| 100 | + */ |
| 101 | + public function getNotFileSpecificErrors(): array |
| 102 | + { |
| 103 | + return $this->notFileSpecificErrors; |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * @return string[] |
| 108 | + */ |
| 109 | + public function getInternalErrors(): array |
| 110 | + { |
| 111 | + return $this->internalErrors; |
| 112 | + } |
| 113 | + |
| 114 | + /** |
| 115 | + * @return string[] |
| 116 | + */ |
| 117 | + public function getWarnings(): array |
| 118 | + { |
| 119 | + return $this->warnings; |
| 120 | + } |
| 121 | + |
| 122 | + public function hasWarnings(): bool |
| 123 | + { |
| 124 | + return count($this->warnings) > 0; |
| 125 | + } |
| 126 | + |
| 127 | + public function hasInternalErrors(): bool |
| 128 | + { |
| 129 | + return count($this->internalErrors) > 0; |
| 130 | + } |
133 | 131 | } |
0 commit comments