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.
Completed
Push — master ( e72770...dceff7 )
by Mario
38:28
created

Aggregate   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 51
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A addVisitor() 0 4 1
A accept() 0 4 1
A visit() 0 12 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\Core\Persistence\Anonymizer\Visitor\Field;
6
7
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
8
use Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor;
9
use Netgen\InformationCollection\Doctrine\Entity\EzInfoCollectionAttribute;
10
use OutOfBoundsException;
11
12
class Aggregate extends FieldAnonymizerVisitor
13
{
14
    /**
15
     * @var \Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor[]
16
     */
17
    protected $visitors;
18
19
    /**
20
     * Aggregate constructor.
21
     *
22
     * @param array $visitors
23
     */
24
    public function __construct(array $visitors = [])
25
    {
26
        foreach ($visitors as $visitor) {
27
            $this->addVisitor($visitor);
28
        }
29
    }
30
31
    /**
32
     * @param \Netgen\InformationCollection\API\Persistence\Anonymizer\Visitor\FieldAnonymizerVisitor $visitor
33
     */
34
    public function addVisitor(FieldAnonymizerVisitor $visitor)
35
    {
36
        $this->visitors[] = $visitor;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function accept(EzInfoCollectionAttribute $ezInfoCollectionAttribute, ContentType $contentType): bool
43
    {
44
        return true;
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function visit(EzInfoCollectionAttribute $ezInfoCollectionAttribute, ContentType $contentType): string
51
    {
52
        foreach ($this->visitors as $visitor) {
53
            if ($visitor->accept($ezInfoCollectionAttribute, $contentType)) {
54
                return $visitor->visit($ezInfoCollectionAttribute, $contentType);
55
            }
56
        }
57
58
        throw new OutOfBoundsException(
59
            'No visitor registered for field anonymization'
60
        );
61
    }
62
}
63