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.

UrlGeneratorRegistry::hasGenerators()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Hateoas\UrlGenerator;
4
5
/**
6
 * @author Adrien Brault <[email protected]>
7
 */
8
class UrlGeneratorRegistry
9
{
10
    const DEFAULT_URL_GENERATOR_KEY = 'default';
11
12
    private $urlGenerators;
13
14
    public function __construct(UrlGeneratorInterface $defaultUrlGenerator = null)
15
    {
16
        $this->urlGenerators = array();
17
18
        if (null !== $defaultUrlGenerator) {
19
            $this->urlGenerators = array(
20
                self::DEFAULT_URL_GENERATOR_KEY => $defaultUrlGenerator,
21
            );
22
        }
23
    }
24
25
    /**
26
     * @param string|null $name If null it will return the default url generator
27
     *
28
     * @return UrlGeneratorInterface
29
     */
30
    public function get($name = null)
31
    {
32
        if (null === $name) {
33
            $name = self::DEFAULT_URL_GENERATOR_KEY;
34
        }
35
36
        if (!isset($this->urlGenerators[$name])) {
37
            throw new \InvalidArgumentException(
38
                sprintf(
39
                    'The "%s" url generator is not set. Available url generators are: %s.',
40
                    $name,
41
                    join(', ', array_keys($this->urlGenerators))
42
                )
43
            );
44
        }
45
46
        return $this->urlGenerators[$name];
47
    }
48
49
    /**
50
     * @param string|null           $name
51
     * @param UrlGeneratorInterface $urlGenerator
52
     */
53
    public function set($name, UrlGeneratorInterface $urlGenerator)
54
    {
55
        if (null === $name) {
56
            $name = self::DEFAULT_URL_GENERATOR_KEY;
57
        }
58
59
        $this->urlGenerators[$name] = $urlGenerator;
60
    }
61
62
    /**
63
     * @return boolean
64
     */
65
    public function hasGenerators()
66
    {
67
        return count($this->urlGenerators) > 0;
68
    }
69
}
70