ParticipationManagerFactory::createService()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 10
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
/**
3
 * This file is part of phpab/phpab-module. (https://github.com/phpab/phpab-module)
4
 *
5
 * @link https://github.com/phpab/phpab-module for the canonical source repository
6
 * @copyright Copyright (c) 2015-2016 phpab. (https://github.com/phpab/)
7
 * @license https://raw.githubusercontent.com/phpab/phpab-module/master/LICENSE MIT
8
 */
9
10
namespace PhpAbModule\Service;
11
12
use PhpAb\Engine\Engine;
13
use PhpAb\Participation\Manager;
14
use RuntimeException;
15
use Zend\ServiceManager\FactoryInterface;
16
use Zend\ServiceManager\ServiceLocatorInterface;
17
18
class ParticipationManagerFactory implements FactoryInterface
19
{
20
    public function createService(ServiceLocatorInterface $serviceLocator)
21
    {
22
        if (!$serviceLocator->has('phpab.storage')) {
23
            throw new RuntimeException('Missing service "phpab.storage" so cannot create participation manager.');
24
        }
25
26
        $storage = $serviceLocator->get('phpab.storage');
27
28
        return new Manager($storage);
0 ignored issues
show
Documentation introduced by
$storage is of type object|array, but the function expects a object<PhpAb\Storage\StorageInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
29
    }
30
}
31