1 | <?php |
||
2 | declare(strict_types = 1); |
||
3 | |||
4 | namespace Fixtures\Innmind\Immutable; |
||
5 | |||
6 | use Innmind\BlackBox\Set as DataSet; |
||
7 | use Innmind\Immutable\Set as Structure; |
||
8 | |||
9 | /** |
||
10 | * {@inheritdoc} |
||
11 | * @template I |
||
12 | */ |
||
13 | final class Set implements DataSet |
||
14 | { |
||
15 | private $type; |
||
16 | private $set; |
||
17 | private $sizes; |
||
18 | |||
19 | public function __construct(string $type, DataSet $set, DataSet\Integers $sizes = null) |
||
0 ignored issues
–
show
|
|||
20 | { |
||
21 | $this->type = $type; |
||
22 | $this->set = $set; |
||
23 | $this->sizes = ($sizes ?? DataSet\Integers::between(0, 100))->take(100); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * @return Set<Structure<I>> |
||
28 | */ |
||
29 | public static function of(string $type, DataSet $set, DataSet\Integers $sizes = null): self |
||
30 | { |
||
31 | return new self($type, $set, $sizes); |
||
32 | } |
||
33 | |||
34 | public function take(int $size): DataSet |
||
35 | { |
||
36 | $self = clone $this; |
||
37 | $self->sizes = $this->sizes->take($size); |
||
38 | |||
39 | return $self; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | public function filter(callable $predicate): DataSet |
||
46 | { |
||
47 | throw new \LogicException('Set set can\'t be filtered, underlying set must be filtered beforehand'); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return \Generator<Set\Value<Structure<I>>> |
||
52 | */ |
||
53 | public function values(): \Generator |
||
54 | { |
||
55 | $immutable = $this->set->values()->current()->isImmutable(); |
||
56 | |||
57 | foreach ($this->sizes->values() as $size) { |
||
58 | if ($immutable) { |
||
59 | yield DataSet\Value::immutable($this->generate($size->unwrap())); |
||
0 ignored issues
–
show
The type
Innmind\BlackBox\Set\Value was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths
Loading history...
|
|||
60 | } else { |
||
61 | yield DataSet\Value::mutable(fn() => $this->generate($size->unwrap())); |
||
62 | } |
||
63 | } |
||
64 | } |
||
65 | |||
66 | private function generate(int $size): Structure |
||
67 | { |
||
68 | $set = Structure::of($this->type); |
||
69 | $values = $this->set->take($size)->values(); |
||
70 | |||
71 | while ($set->size() < $size) { |
||
72 | $set = ($set)($values->current()->unwrap()); |
||
73 | $values->next(); |
||
74 | } |
||
75 | |||
76 | return $set; |
||
77 | } |
||
78 | } |
||
79 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths