BugPreventingFactor::calculate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 3
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 3
loc 3
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
1
<?php
2
3
/*
4
* (c) Jean-François Lépine <https://twitter.com/Halleck45>
5
*
6
* For the full copyright and license information, please view the LICENSE
7
* file that was distributed with this source code.
8
*/
9
10
namespace Hal\Application\Score\Factor;
11
12
use Hal\Application\Score\Calculator;
13
use Hal\Component\Bounds\Result\ResultInterface;
14
use Hal\Component\Result\ResultCollection;
15
16
/**
17
 * Is the code complex ?
18
 *
19
 * @author Jean-François Lépine <https://twitter.com/Halleck45>
20
 */
21 View Code Duplication
class BugPreventingFactor implements FactorInterface {
0 ignored issues
show
Duplication introduced by
This class 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...
22
23
    /**
24
     * Bounds
25
     *
26
     * @var Calculator
27
     */
28
    private $calculator;
29
30
    /**
31
     * Constructor
32
     *
33
     * @param Calculator $calculator
34
     */
35
    public function __construct(Calculator $calculator)
36
    {
37
        $this->calculator = $calculator;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function calculate(ResultCollection $collection, ResultCollection $groupedResults, ResultInterface $bound) {
44
        return round($this->calculator->lowIsBetter(0.09, 0.70, $bound->getAverage('bugs')), 2);
45
    }
46
47
    /**
48
     * @inheritedDoc
49
     */
50
    public function getName() {
51
        return 'Reducing bug\'s probability';
52
    }
53
}