Completed
Push — master ( 638b8d...de83b5 )
by John
01:47 queued 17s
created

FactoryQueue::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of the KleijnWeb\PhpApi\Hydrator package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\PhpApi\Hydrator\Processors\Factory;
10
11
/**
12
 * @author John Kleijn <[email protected]>
13
 */
14
class FactoryQueue extends \SplPriorityQueue
15
{
16
    /**
17
     * @var int
18
     */
19
    protected $serial = PHP_INT_MAX;
20
21
    /**
22
     * PriorityQueue constructor.
23
     * @param Factory[] ...$factories
24
     */
25
    public function __construct(Factory ...$factories)
26
    {
27
        foreach ($factories as $factory) {
28
            $this->add($factory);
0 ignored issues
show
Documentation introduced by
$factory is of type array<integer,object<Kle...ssors\Factory\Factory>>, but the function expects a object<KleijnWeb\PhpApi\...essors\Factory\Factory>.

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
32
    /**
33
     * @param Factory $factory
34
     */
35
    public function add(Factory $factory)
36
    {
37
        $this->insert($factory, $factory->getPriority());
38
    }
39
40
    /**
41
     * @param mixed $value
42
     * @param mixed $priority
43
     */
44
    public function insert($value, $priority)
45
    {
46
        parent::insert($value, [$priority, $this->serial--]);
47
    }
48
}
49