Passed
Push — master ( de185f...587e15 )
by Doug
07:26
created

Html   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 16
dl 0
loc 45
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 4
A process() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
/**
5
 * Code Coverage HTML Report.
6
 *
7
 * @copyright 2013 Anthon Pang
8
 *
9
 * @license BSD-3-Clause
10
 */
11
12
namespace DVDoug\Behat\CodeCoverage\Common\Report;
13
14
use DVDoug\Behat\CodeCoverage\Common\ReportInterface;
15
use SebastianBergmann\CodeCoverage\CodeCoverage;
16
use SebastianBergmann\CodeCoverage\Report\Html\Facade;
17
18
/**
19
 * HTML report.
20
 *
21
 * @author Anthon Pang <[email protected]>
22
 */
23
class Html implements ReportInterface
24
{
25
    /**
26
     * @var Facade
27
     */
28
    private $report;
29
30
    /**
31
     * @var array
32
     */
33
    private $options;
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function __construct(array $options)
39
    {
40
        if (!isset($options['target'])) {
41
            $options['target'] = null;
42
        }
43
44
        if (!isset($options['lowUpperBound'])) {
45
            $options['lowUpperBound'] = 50;
46
        }
47
48
        if (!isset($options['highLowerBound'])) {
49
            $options['highLowerBound'] = 90;
50
        }
51
52
        $this->report = new Facade(
53
            $options['lowUpperBound'],
54
            $options['highLowerBound']
55
        );
56
57
        $this->options = $options;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function process(CodeCoverage $coverage)
64
    {
65
        return $this->report->process(
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->report->process($...his->options['target']) targeting SebastianBergmann\CodeCo...\Html\Facade::process() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Bug Best Practice introduced by
The expression return $this->report->pr...his->options['target']) returns the type void which is incompatible with the return type mandated by DVDoug\Behat\CodeCoverag...ortInterface::process() of null|string.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
66
            $coverage,
67
            $this->options['target']
68
        );
69
    }
70
}
71