Passed
Push — master ( c0afab...574a9e )
by Luke
09:17
created

GitPackageRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 3 3 1
A getName() 3 3 1
A getComponent() 7 7 1
A satisfiesVersion() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * Moodle component manager.
5
 *
6
 * @author Luke Carrier <[email protected]>
7
 * @copyright 2016 Luke Carrier
8
 * @license GPL-3.0+
9
 */
10
11
namespace ComponentManager\PackageRepository;
12
13
use ComponentManager\Component;
14
use ComponentManager\ComponentSource\GitComponentSource;
15
use ComponentManager\ComponentSpecification;
16
use ComponentManager\ComponentVersion;
17
use Github\Client;
18
use Github\HttpClient\CachedHttpClient;
19
20
/**
21
 * Git package repository.
22
 *
23
 * Allows sourcing components from arbitrary Git repositories.
24
 */
25 View Code Duplication
class GitPackageRepository extends AbstractCachingPackageRepository
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
        implements PackageRepository {
27
    /**
28
     * @override \ComponentManager\PackageRepository\PackageRepository
29
     */
30
    public function getId() {
31
        return 'Git';
32
    }
33
34
    /**
35
     * @override \ComponentManager\PackageRepository\PackageRepository
36
     */
37
    public function getName() {
38
        return 'Git package repository';
39
    }
40
41
    /**
42
     * @override \ComponentManager\PackageRepository\PackageRepository
43
     */
44
    public function getComponent(ComponentSpecification $componentSpecification) {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 82 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
45
        return new Component($componentSpecification->getName(), [
46
            new ComponentVersion(null, null, null, [
47
                new GitComponentSource($componentSpecification->getExtra('uri'), $componentSpecification->getVersion())
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 119 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
48
            ]),
49
        ], $this);
50
    }
51
52
    /**
53
     * @override \ComponentManager\PackageRepository\PackageRepository
54
     */
55
    public function satisfiesVersion($versionSpecification, ComponentVersion $version) {
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 88 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
56
        return true;
57
    }
58
}
59