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.

FieldHandlerRegistry::addHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Netgen\InformationCollection\Core\Persistence\FieldHandler;
6
7
use eZ\Publish\Core\FieldType\Value;
8
use Netgen\InformationCollection\API\FieldHandler\CustomFieldHandlerInterface;
9
10
final class FieldHandlerRegistry
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $handlers;
16
17
    /**
18
     * FieldHandlerRegistry constructor.
19
     *
20
     * @param array $handlers
21
     */
22
    public function __construct(iterable $handlers)
23
    {
24
        $this->handlers = $handlers;
25
    }
26
27
    /**
28
     * Adds new handler.
29
     *
30
     * @param CustomFieldHandlerInterface $handler
31
     */
32
    public function addHandler(CustomFieldHandlerInterface $handler): void
33
    {
34
        $this->handlers[] = $handler;
35
    }
36
37
    /**
38
     * @param Value $value
39
     *
40
     * @return CustomFieldHandlerInterface|null
41
     */
42
    public function handle(Value $value): ?CustomFieldHandlerInterface
43
    {
44
        /** @var CustomFieldHandlerInterface $handler */
45
        foreach ($this->handlers as $handler) {
46
            if ($handler->supports($value)) {
47
                return $handler;
48
            }
49
        }
50
51
        return null;
52
    }
53
}
54