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
Pull Request — master (#159)
by Roman
01:49
created

Endpoint   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
c 0
b 0
f 0
lcom 2
cbo 3
dl 0
loc 93
rs 10
ccs 26
cts 26
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAlias() 0 13 2
A supportsRegion() 0 4 1
A supportsUrlType() 0 14 4
A getUrl() 0 18 4
1
<?php declare(strict_types=1);
2
3
namespace OpenStack\Identity\v2\Models;
4
5
use OpenStack\Common\HydratorStrategyTrait;
6
use OpenStack\Common\Resource\Alias;
7
use OpenStack\Common\Resource\OperatorResource;
8
9
/**
10
 * Represents an Identity v2 catalog entry endpoint.
11
 *
12
 * @package OpenStack\Identity\v2\Models
13
 */
14
class Endpoint extends OperatorResource
15
{
16
    use HydratorStrategyTrait;
17
18
    /** @var string */
19
    public $adminUrl;
20
21
    /** @var string */
22
    public $region;
23
24
    /** @var string */
25
    public $internalUrl;
26
27
    /** @var string */
28
    public $publicUrl;
29
30
    /**
31
     * @inheritdoc
32
     */
33
    protected static function getAlias(): Alias
34
    {
35
        $alias = parent::getAlias();
36
37
        if (!$alias->hasAliases(self::class)) {
38
            $alias
39
                ->add(self::class, 'adminURL', 'adminUrl')
40
                ->add(self::class, 'internalURL', 'internalUrl')
41
                ->add(self::class, 'publicURL', 'publicUrl');
42 1
        }
43
44 1
        return $alias;
45
    }
46
47
    /**
48
     * Indicates whether a given region is supported
49
     *
50
     * @param string $region
51
     *
52
     * @return bool
53
     */
54 1
    public function supportsRegion(string $region): bool
55
    {
56 1
        return $this->region == $region;
57
    }
58 1
59 1
    /**
60 1
     * Indicates whether a given URL type is supported
61 1
     *
62 1
     * @param string $urlType
63 1
     *
64 1
     * @return bool
65
     */
66 1
    public function supportsUrlType(string $urlType): bool
67
    {
68
        $supported = false;
69
70
        switch (strtolower($urlType)) {
71
            case 'internalurl':
72
            case 'publicurl':
73
            case 'adminurl':
74
                $supported = true;
75
                break;
76 3
        }
77
78 3
        return $supported;
79
    }
80 3
81 3
    /**
82 1
     * Retrieves a URL for the endpoint based on a specific type.
83 1
     *
84 2
     * @param string $urlType Either "internalURL", "publicURL" or "adminURL" (case insensitive)
85 1
     *
86 1
     * @return bool|string
87 1
     */
88 1
    public function getUrl(string $urlType): string
89 1
    {
90 3
        $url = false;
91
92 3
        switch (strtolower($urlType)) {
93
            case 'internalurl':
94
                $url = $this->internalUrl;
95
                break;
96
            case 'publicurl':
97
                $url = $this->publicUrl;
98
                break;
99
            case 'adminurl':
100
                $url = $this->adminUrl;
101
                break;
102
        }
103
104
        return $url;
105
    }
106
}
107