Passed
Branch benchmark (b81757)
by Jose
10:16
created

Result::filterHasSolution()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "Result.php" doesn't match the expected filename "result.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace JMGQ\AStar\Benchmark\Result;
4
5
class Result
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
6
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Result
Loading history...
7
    private $size;
0 ignored issues
show
Coding Style introduced by
Private member variable "size" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "size" must be prefixed with an underscore
Loading history...
8
    private $duration;
0 ignored issues
show
Coding Style introduced by
Private member variable "duration" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "duration" must be prefixed with an underscore
Loading history...
9
    private $hasSolution;
0 ignored issues
show
Coding Style introduced by
Private member variable "hasSolution" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "hasSolution" must be prefixed with an underscore
Loading history...
10
11
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
12
     * @param int $size
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
13
     * @param int $duration
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
14
     * @param bool $hasSolution
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "boolean" but found "bool" for parameter type
Loading history...
15
     */
16
    public function __construct($size, $duration, $hasSolution)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Type hint "int" missing for $size
Loading history...
Coding Style introduced by
Type hint "int" missing for $duration
Loading history...
Coding Style introduced by
Type hint "bool" missing for $hasSolution
Loading history...
17
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
18
        $this->size = $this->filterSize($size);
0 ignored issues
show
Coding Style introduced by
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.

Loading history...
19
        $this->duration = $this->filterDuration($duration);
0 ignored issues
show
Coding Style introduced by
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.

Loading history...
20
        $this->hasSolution = $this->filterHasSolution($hasSolution);
21
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __construct()
Loading history...
22
23
    public function getSize()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
24
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
25
        return $this->size;
26
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getSize()
Loading history...
27
28
    public function getDuration()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
29
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
30
        return $this->duration;
31
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getDuration()
Loading history...
32
33
    public function hasSolution()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
34
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
35
        return $this->hasSolution;
36
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end hasSolution()
Loading history...
37
38 View Code Duplication
    private function filterSize($size)
0 ignored issues
show
Coding Style introduced by
Private method name "Result::filterSize" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
Duplication introduced by
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.

Loading history...
39
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
40
        $naturalNumber = filter_var($size, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1)));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
41
42
        if ($naturalNumber === false) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of false please use FALSE.
Loading history...
43
            throw new \InvalidArgumentException('Invalid size: ' . print_r($size, true));
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
44
        }
45
46
        return $naturalNumber;
47
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end filterSize()
Loading history...
48
49 View Code Duplication
    private function filterDuration($duration)
0 ignored issues
show
Coding Style introduced by
Private method name "Result::filterDuration" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
Duplication introduced by
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.

Loading history...
50
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
51
        $nonNegativeInteger = filter_var($duration, FILTER_VALIDATE_INT, array('options' => array('min_range' => 0)));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
52
53
        if ($nonNegativeInteger === false) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of false please use FALSE.
Loading history...
54
            throw new \InvalidArgumentException('Invalid duration: ' . print_r($duration, true));
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
55
        }
56
57
        return $nonNegativeInteger;
58
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end filterDuration()
Loading history...
59
60
    private function filterHasSolution($hasSolution)
0 ignored issues
show
Coding Style introduced by
Private method name "Result::filterHasSolution" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
61
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
62
        return filter_var($hasSolution, FILTER_VALIDATE_BOOLEAN);
63
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end filterHasSolution()
Loading history...
64
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
65