Service::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 7
nc 1
nop 3
crap 1
1
<?php
2
namespace Bookdown\Bookdown\Service;
3
4
class Service
5
{
6
    protected $collector;
7
    protected $processorBuilder;
8
    protected $timer;
9
10 3
    public function __construct(
11
        Collector $collector,
12
        ProcessorBuilder $processorBuilder,
13
        Timer $timer
14
    ) {
15 3
        $this->collector = $collector;
16 3
        $this->processorBuilder = $processorBuilder;
17 3
        $this->timer = $timer;
18 3
    }
19
20 1
    public function __invoke($rootConfigFile, array $rootConfigOverrides)
21
    {
22 1
        $this->collector->setRootConfigOverrides($rootConfigOverrides);
23 1
        $rootPage = $this->collector->__invoke($rootConfigFile);
24 1
        $processor = $this->processorBuilder->newProcessor($rootPage->getConfig());
25 1
        $processor->__invoke($rootPage);
0 ignored issues
show
Compatibility introduced by
$rootPage of type object<Bookdown\Bookdown\Content\Page> is not a sub-type of object<Bookdown\Bookdown\Content\RootPage>. It seems like you assume a child class of the class Bookdown\Bookdown\Content\Page to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
26 1
        $this->timer->report();
27 1
    }
28
}
29