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 — 4.2-to-master ( ed215f )
by E
06:47
created

NamespaceUrlFilters   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A subgroupName() 0 10 2
B namespaceLinks() 0 18 5
A namespaceUrl() 0 7 1
1
<?php declare(strict_types=1);
2
3
namespace ApiGen\Templating\Filters;
4
5
use ApiGen\Configuration\Configuration;
6
use ApiGen\Configuration\ConfigurationOptions;
7
use ApiGen\Parser\Elements\ElementStorage;
8
use ApiGen\Templating\Filters\Helpers\LinkBuilder;
9
10
class NamespaceUrlFilters extends Filters
11
{
12
    /**
13
     * @var Configuration
14
     */
15
    private $configuration;
16
17
    /**
18
     * @var LinkBuilder
19
     */
20
    private $linkBuilder;
21
22
    /**
23
     * @var ElementStorage
24
     */
25
    private $elementStorage;
26
27
    public function __construct(Configuration $configuration, LinkBuilder $linkBuilder, ElementStorage $elementStorage)
28
    {
29
        $this->configuration = $configuration;
30
        $this->linkBuilder = $linkBuilder;
31
        $this->elementStorage = $elementStorage;
32
    }
33
34
    public function subgroupName(string $groupName): string
35
    {
36
        $pos = strrpos($groupName, '\\');
37
38
        if ($pos) {
39
            return substr($groupName, $pos + 1);
40
        }
41
42
        return $groupName;
43
    }
44
45
    public function namespaceLinks(string $namespace, bool $skipLast = true): string
46
    {
47
        if (! $this->elementStorage->getNamespaces()) {
48
            return $namespace;
49
        }
50
51
        $links = [];
52
53
        $parent = '';
54
        foreach (explode('\\', $namespace) as $part) {
55
            $parent = ltrim($parent . '\\' . $part, '\\');
56
            $links[] = $skipLast || $parent !== $namespace
57
                ? $this->linkBuilder->build($this->namespaceUrl($parent), $part)
58
                : $part;
59
        }
60
61
        return implode('\\', $links);
62
    }
63
64
    public function namespaceUrl(string $name): string
65
    {
66
        return sprintf(
67
            $this->configuration->getOption(ConfigurationOptions::TEMPLATE)['templates']['namespace']['filename'],
68
            $this->urlize($name)
69
        );
70
    }
71
}
72