GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — develop ( 4471cd...dae846 )
by Baptiste
03:11
created

Set   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 24
c 1
b 0
f 1
dl 0
loc 64
rs 10
wmc 9

6 Methods

Rating   Name   Duplication   Size   Complexity  
A filter() 0 3 1
A take() 0 6 1
A values() 0 9 3
A generate() 0 11 2
A __construct() 0 5 1
A of() 0 3 1
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
Bug introduced by
The type Innmind\BlackBox\Set\Integers 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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
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
Bug introduced by
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. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

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