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 ( ddbc41...cff4e7 )
by Loick
6s
created

GitBasedUrlGenerator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 43
ccs 16
cts 16
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generateBaseUrl() 0 12 2
A getCompareVersion() 0 11 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
abstract class GitBasedUrlGenerator implements UrlGenerator
17
{
18
    /**
19
     * Generates the base url for a repository by removing the .git part.
20
     *
21
     * @param string $sourceUrl
22
     *
23
     * @return string
24
     */
25 23
    protected function generateBaseUrl($sourceUrl)
26
    {
27 23
        $sourceUrl = parse_url($sourceUrl);
28 23
        $pos = strrpos($sourceUrl['path'], '.git');
29
30 23
        return sprintf(
31 23
            '%s://%s%s',
32 23
            $sourceUrl['scheme'],
33 23
            $sourceUrl['host'],
34 23
            $pos === false ? $sourceUrl['path'] : substr($sourceUrl['path'], 0, strrpos($sourceUrl['path'], '.git'))
35 23
        );
36
    }
37
38
    /**
39
     * Get the version to use for the compare url.
40
     *
41
     * For dev versions, it returns the commit short hash in full pretty version.
42
     *
43
     * @param Version $version
44
     *
45
     * @return string
46
     */
47 17
    protected function getCompareVersion(Version $version)
48
    {
49 17
        if ($version->isDev()) {
50 4
            return substr(
51 4
                $version->getFullPretty(),
52 4
                strlen($version->getPretty()) + 1
53 4
            );
54
        }
55
56 17
        return $version->getPretty();
57
    }
58
}
59