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.

BitbucketUrlGenerator   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 58
ccs 28
cts 28
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDomain() 0 4 1
B generateCompareUrl() 0 35 4
A generateReleaseUrl() 0 5 1
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 BitbucketUrlGenerator 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 16
    protected function getDomain()
22
    {
23 16
        return 'bitbucket.org';
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 12
    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 12
        if (!$this->supports($sourceUrlFrom) || !$this->supports($sourceUrlTo)) {
34 2
            return false;
35
        }
36
37 10
        $sourceUrlFrom = $this->generateBaseUrl($sourceUrlFrom);
38 10
        $sourceUrlTo = $this->generateBaseUrl($sourceUrlTo);
39
40
        // Check if comparison across forks is needed
41 10
        if ($sourceUrlFrom !== $sourceUrlTo) {
42 4
            $repositoryFrom = $this->extractRepositoryInformation($sourceUrlFrom);
43 4
            $repositoryTo = $this->extractRepositoryInformation($sourceUrlTo);
44
45 2
            return sprintf(
46 2
                '%s/branches/compare/%s/%s:%s%%0D%s/%s:%s',
47 2
                $sourceUrlTo,
48 2
                $repositoryTo['user'],
49 2
                $repositoryTo['repository'],
50 2
                $this->getCompareVersion($versionTo),
51 2
                $repositoryFrom['user'],
52 2
                $repositoryFrom['repository'],
53 2
                $this->getCompareVersion($versionFrom)
54 2
            );
55
        }
56
57 6
        return sprintf(
58 6
            '%s/branches/compare/%s%%0D%s',
59 6
            $sourceUrlTo,
60 6
            $this->getCompareVersion($versionTo),
61 6
            $this->getCompareVersion($versionFrom)
62 6
        );
63
    }
64
65
    /**
66
     * {@inheritdoc}
67
     */
68 2
    public function generateReleaseUrl($sourceUrl, Version $version)
69
    {
70
        // Releases are not supported on Bitbucket :'(
71 2
        return false;
72
    }
73
}
74