Conditions | 1 |
Paths | 1 |
Total Lines | 4 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Metric | Value |
---|---|
dl | 0 |
loc | 4 |
rs | 10 |
c | 0 |
b | 0 |
f | 0 |
cc | 1 |
nc | 1 |
nop | 0 |
1 | <?php |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
2 | |||
0 ignored issues
–
show
|
|||
3 | namespace JMGQ\AStar\Benchmark\Result; |
||
4 | |||
5 | class Result |
||
0 ignored issues
–
show
|
|||
6 | { |
||
0 ignored issues
–
show
|
|||
7 | private $size; |
||
0 ignored issues
–
show
|
|||
8 | private $duration; |
||
0 ignored issues
–
show
|
|||
9 | private $hasSolution; |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | /** |
||
0 ignored issues
–
show
|
|||
12 | * @param int $size |
||
0 ignored issues
–
show
|
|||
13 | * @param int $duration |
||
0 ignored issues
–
show
|
|||
14 | * @param bool $hasSolution |
||
0 ignored issues
–
show
|
|||
15 | */ |
||
16 | public function __construct($size, $duration, $hasSolution) |
||
0 ignored issues
–
show
|
|||
17 | { |
||
0 ignored issues
–
show
|
|||
18 | $this->size = $this->filterSize($size); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
19 | $this->duration = $this->filterDuration($duration); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
20 | $this->hasSolution = $this->filterHasSolution($hasSolution); |
||
21 | } |
||
0 ignored issues
–
show
|
|||
22 | |||
23 | public function getSize() |
||
0 ignored issues
–
show
|
|||
24 | { |
||
0 ignored issues
–
show
|
|||
25 | return $this->size; |
||
26 | } |
||
0 ignored issues
–
show
|
|||
27 | |||
28 | public function getDuration() |
||
0 ignored issues
–
show
|
|||
29 | { |
||
0 ignored issues
–
show
|
|||
30 | return $this->duration; |
||
31 | } |
||
0 ignored issues
–
show
|
|||
32 | |||
33 | public function hasSolution() |
||
0 ignored issues
–
show
|
|||
34 | { |
||
0 ignored issues
–
show
|
|||
35 | return $this->hasSolution; |
||
36 | } |
||
0 ignored issues
–
show
|
|||
37 | |||
38 | View Code Duplication | private function filterSize($size) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
39 | { |
||
0 ignored issues
–
show
|
|||
40 | $naturalNumber = filter_var($size, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1))); |
||
0 ignored issues
–
show
|
|||
41 | |||
42 | if ($naturalNumber === false) { |
||
0 ignored issues
–
show
|
|||
43 | throw new \InvalidArgumentException('Invalid size: ' . print_r($size, true)); |
||
0 ignored issues
–
show
|
|||
44 | } |
||
45 | |||
46 | return $naturalNumber; |
||
47 | } |
||
0 ignored issues
–
show
|
|||
48 | |||
49 | View Code Duplication | private function filterDuration($duration) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
50 | { |
||
0 ignored issues
–
show
|
|||
51 | $nonNegativeInteger = filter_var($duration, FILTER_VALIDATE_INT, array('options' => array('min_range' => 0))); |
||
0 ignored issues
–
show
|
|||
52 | |||
53 | if ($nonNegativeInteger === false) { |
||
0 ignored issues
–
show
|
|||
54 | throw new \InvalidArgumentException('Invalid duration: ' . print_r($duration, true)); |
||
0 ignored issues
–
show
|
|||
55 | } |
||
56 | |||
57 | return $nonNegativeInteger; |
||
58 | } |
||
0 ignored issues
–
show
|
|||
59 | |||
60 | private function filterHasSolution($hasSolution) |
||
0 ignored issues
–
show
|
|||
61 | { |
||
0 ignored issues
–
show
|
|||
62 | return filter_var($hasSolution, FILTER_VALIDATE_BOOLEAN); |
||
63 | } |
||
0 ignored issues
–
show
|
|||
64 | } |
||
0 ignored issues
–
show
|
|||
65 |