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.

Entry::getEndpointUrl()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
rs 9.2
ccs 0
cts 0
cp 0
cc 4
eloc 5
nc 3
nop 2
crap 20
1
<?php declare(strict_types=1);
2
3
namespace OpenStack\Identity\v2\Models;
4
5
use OpenStack\Common\Resource\Alias;
6
use OpenStack\Common\Resource\OperatorResource;
7
8
/**
9
 * Represents an Identity v2 Catalog Entry.
10
 *
11
 * @package OpenStack\Identity\v2\Models
12
 */
13
class Entry extends OperatorResource
14
{
15
    /** @var string */
16
    public $name;
17
18
    /** @var string */
19
    public $type;
20
21
    /** @var []Endpoint */
22
    public $endpoints = [];
23
24
    /**
25
     * @inheritdoc
26
     */
27
    protected function getAliases(): array
28
    {
29
        return parent::getAliases() + [
30
            'endpoints' => new Alias('endpoints', Endpoint::class, true)
31 1
        ];
32
    }
33 1
34
    /**
35
     * Indicates whether this catalog entry matches a certain name and type.
36
     *
37
     * @param string $name
38
     * @param string $type
39
     *
40
     * @return bool TRUE if it's a match, FALSE if not
41
     */
42
    public function matches(string $name, string $type): bool
43
    {
44 2
        return $this->name == $name && $this->type == $type;
45
    }
46 2
47 1
    /**
48 1
     * Retrieves the catalog entry's URL according to a specific region and URL type
49
     *
50 1
     * @param string $region
51
     * @param string $urlType
52 1
     *
53
     * @return string
54
     */
55
    public function getEndpointUrl(string $region, string $urlType): string
56
    {
57
        foreach ($this->endpoints as $endpoint) {
58
            if ($endpoint->supportsRegion($region) && $endpoint->supportsUrlType($urlType)) {
59
                return $endpoint->getUrl($urlType);
60
            }
61
        }
62
63
        return "";
64
    }
65
}
66