Completed
Push — master ( 87f06d...e62357 )
by Loïc
02:09 queued 10s
created

DashboardStatisticsProvider::__construct()   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
2
3
/*
4
 * This file is part of monofony.
5
 *
6
 * (c) Mobizel
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace App\Dashboard;
15
16
use App\Repository\CustomerRepository;
17
use Sylius\Component\Resource\Repository\RepositoryInterface;
18
19
class DashboardStatisticsProvider
20
{
21
    /** @var CustomerRepository */
22
    private $customerRepository;
23
24
    public function __construct(RepositoryInterface $customerRepository)
25
    {
26
        $this->customerRepository = $customerRepository;
0 ignored issues
show
Documentation Bug introduced by
$customerRepository is of type object<Sylius\Component\...ry\RepositoryInterface>, but the property $customerRepository was declared to be of type object<App\Repository\CustomerRepository>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
27
    }
28
29
    public function getStatistics(): DashboardStatistics
30
    {
31
        return new DashboardStatistics(
32
            $this->customerRepository->countCustomers()
33
        );
34
    }
35
}
36