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::generateCompareUrl()   B
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 35
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 24
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 24
cts 24
cp 1
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 22
nc 3
nop 4
crap 4
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