Total Complexity | 6 |
Total Lines | 56 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
8 | final class FactoryCollection |
||
9 | { |
||
10 | /** @var Factory */ |
||
11 | private $factory; |
||
12 | |||
13 | /** @var int */ |
||
14 | private $min; |
||
15 | |||
16 | /** @var int */ |
||
17 | private $max; |
||
18 | |||
19 | /** |
||
20 | * @param int|null $max If set, when created, the collection will be a random size between $min and $max |
||
21 | */ |
||
22 | public function __construct(Factory $factory, int $min, ?int $max = null) |
||
23 | { |
||
24 | if ($max && $min > $max) { |
||
|
|||
25 | throw new \InvalidArgumentException('Min must be less than max.'); |
||
26 | } |
||
27 | |||
28 | $this->factory = $factory; |
||
29 | $this->min = $min; |
||
30 | $this->max = $max ?? $min; |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @param array|callable $attributes |
||
35 | * |
||
36 | * @return Proxy[]|object[] |
||
37 | */ |
||
38 | public function create($attributes = []): array |
||
45 | ); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return Factory[] |
||
50 | */ |
||
51 | public function all(): array |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | public function factory(): Factory |
||
66 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: