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 — master ( 5ca23c...9db431 )
by Loick
7s
created

GithubUrlGenerator   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 7
Bugs 1 Features 4
Metric Value
wmc 7
c 7
b 1
f 4
lcom 1
cbo 2
dl 0
loc 63
ccs 32
cts 32
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDomain() 0 4 1
B generateCompareUrl() 0 33 4
A generateReleaseUrl() 0 12 2
1
<?php
2
3
/*
4
 * This file is part of the composer-changelogs project.
5
 *
6
 * (c) Loïck Piera <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Pyrech\ComposerChangelogs\UrlGenerator;
13
14
use Pyrech\ComposerChangelogs\Version;
15
16
class GithubUrlGenerator extends AbstractUrlGenerator
0 ignored issues
show
Deprecated Code introduced by
The class Pyrech\ComposerChangelog...or\AbstractUrlGenerator has been deprecated with message: since v1.4, will be removed in v2.0. Use GitBasedUrlGenerator class instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21 23
    protected function getDomain()
22
    {
23 23
        return 'github.com';
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 17
    public function generateCompareUrl($sourceUrlFrom, Version $versionFrom, $sourceUrlTo, Version $versionTo)
30
    {
31
        // Check if both urls come from the supported domain
32
        // It avoids problems when one url is from another domain or is local
33 17
        if (!$this->supports($sourceUrlFrom) || !$this->supports($sourceUrlTo)) {
34 2
            return false;
35
        }
36
37 15
        $sourceUrlFrom = $this->generateBaseUrl($sourceUrlFrom);
38 15
        $sourceUrlTo = $this->generateBaseUrl($sourceUrlTo);
39
40
        // Check if comparison across forks is needed
41 15
        if ($sourceUrlFrom !== $sourceUrlTo) {
42 4
            $repositoryFrom = $this->extractRepositoryInformation($sourceUrlFrom);
43 4
            $repositoryTo = $this->extractRepositoryInformation($sourceUrlTo);
44
45 2
            return sprintf(
46 2
                '%s/compare/%s:%s...%s:%s',
47 2
                $sourceUrlTo,
48 2
                $repositoryFrom['user'],
49 2
                $this->getCompareVersion($versionFrom),
50 2
                $repositoryTo['user'],
51 2
                $this->getCompareVersion($versionTo)
52 2
            );
53
        }
54
55 11
        return sprintf(
56 11
            '%s/compare/%s...%s',
57 11
            $sourceUrlTo,
58 11
            $this->getCompareVersion($versionFrom),
59 11
            $this->getCompareVersion($versionTo)
60 11
        );
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66 11
    public function generateReleaseUrl($sourceUrl, Version $version)
67
    {
68 11
        if ($version->isDev()) {
69 2
            return false;
70
        }
71
72 9
        return sprintf(
73 9
            '%s/releases/tag/%s',
74 9
            $this->generateBaseUrl($sourceUrl),
75 9
            $version->getPretty()
76 9
        );
77
    }
78
}
79