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

AggregatedResult::getMaximumDuration()   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 0
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 "AggregatedResult.php" doesn't match the expected filename "aggregatedresult.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 AggregatedResult
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 AggregatedResult
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 $averageDuration;
0 ignored issues
show
Coding Style introduced by
Private member variable "averageDuration" 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 "averageDuration" must be prefixed with an underscore
Loading history...
9
    private $minimumDuration;
0 ignored issues
show
Coding Style introduced by
Private member variable "minimumDuration" 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 "minimumDuration" must be prefixed with an underscore
Loading history...
10
    private $maximumDuration;
0 ignored issues
show
Coding Style introduced by
Private member variable "maximumDuration" 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 "maximumDuration" must be prefixed with an underscore
Loading history...
11
    private $numberOfSolutions;
0 ignored issues
show
Coding Style introduced by
Private member variable "numberOfSolutions" 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 "numberOfSolutions" must be prefixed with an underscore
Loading history...
12
    private $numberOfTerrains;
0 ignored issues
show
Coding Style introduced by
Private member variable "numberOfTerrains" 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 "numberOfTerrains" must be prefixed with an underscore
Loading history...
13
14
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
15
     * @param int $size
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
16
     * @param int $averageDuration
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
17
     * @param int $minimumDuration
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
18
     * @param int $maximumDuration
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
19
     * @param int $numberOfSolutions
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
20
     * @param int $numberOfTerrains
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
21
     */
22
    public function __construct(
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 $averageDuration
Loading history...
Coding Style introduced by
Type hint "int" missing for $minimumDuration
Loading history...
Coding Style introduced by
Type hint "int" missing for $maximumDuration
Loading history...
Coding Style introduced by
Type hint "int" missing for $numberOfSolutions
Loading history...
Coding Style introduced by
Type hint "int" missing for $numberOfTerrains
Loading history...
23
        $size,
24
        $averageDuration,
25
        $minimumDuration,
26
        $maximumDuration,
27
        $numberOfSolutions,
28
        $numberOfTerrains
29
    ) {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on a new line
Loading history...
30
        $this->size = $this->filterNaturalNumber($size, 'size');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 14 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...
31
        $this->averageDuration = $this->filterNonNegativeInteger($averageDuration, 'average duration');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
32
        $this->minimumDuration = $this->filterNonNegativeInteger($minimumDuration, 'minimum duration');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
33
        $this->maximumDuration = $this->filterNonNegativeInteger($maximumDuration, 'maximum duration');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 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...
34
        $this->numberOfSolutions = $this->filterNonNegativeInteger($numberOfSolutions, 'number of solutions');
35
        $this->numberOfTerrains = $this->filterNaturalNumber($numberOfTerrains, 'number of terrains');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 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...
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 __construct()
Loading history...
37
38
    public function getSize()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
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
        return $this->size;
41
    }
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...
42
43
    public function getAverageDuration()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
44
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
45
        return $this->averageDuration;
46
    }
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 getAverageDuration()
Loading history...
47
48
    public function getMinimumDuration()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
49
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
50
        return $this->minimumDuration;
51
    }
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 getMinimumDuration()
Loading history...
52
53
    public function getMaximumDuration()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
54
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
55
        return $this->maximumDuration;
56
    }
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 getMaximumDuration()
Loading history...
57
58
    public function getNumberOfSolutions()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
59
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
60
        return $this->numberOfSolutions;
61
    }
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 getNumberOfSolutions()
Loading history...
62
63
    public function getNumberOfTerrains()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
64
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
65
        return $this->numberOfTerrains;
66
    }
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 getNumberOfTerrains()
Loading history...
67
68
    private function filterNaturalNumber($value, $parameterName)
0 ignored issues
show
Coding Style introduced by
Private method name "AggregatedResult::filterNaturalNumber" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
69
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
70
        $naturalNumber = filter_var($value, 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...
71
72
        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...
73
            throw new \InvalidArgumentException('Invalid ' . $parameterName . ': ' . print_r($value, 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...
74
        }
75
76
        return $naturalNumber;
77
    }
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 filterNaturalNumber()
Loading history...
78
79
    private function filterNonNegativeInteger($value, $parameterName)
0 ignored issues
show
Coding Style introduced by
Private method name "AggregatedResult::filterNonNegativeInteger" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
80
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
81
        $nonNegativeInteger = filter_var($value, 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...
82
83
        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...
84
            throw new \InvalidArgumentException('Invalid ' . $parameterName . ': ' . print_r($value, 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...
85
        }
86
87
        return $nonNegativeInteger;
88
    }
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 filterNonNegativeInteger()
Loading history...
89
}
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...
90