Test Failed
Push — master ( f875a7...aad9c2 )
by Luke
22:35
created

GitPackageRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 3 3 1
A getName() 3 3 1
A resolveComponent() 8 8 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 Psr\Log\LoggerInterface;
18
19
/**
20
 * Git package repository.
21
 *
22
 * Allows sourcing components from arbitrary Git repositories.
23
 */
24 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...
25
        implements PackageRepository {
26
    /**
27
     * @inheritdoc PackageRepository
28
     */
29
    public function getId() {
30
        return 'Git';
31
    }
32
33
    /**
34
     * @inheritdoc PackageRepository
35
     */
36
    public function getName() {
37
        return 'Git package repository';
38
    }
39
40
    /**
41
     * @inheritdoc PackageRepository
42
     */
43
    public function resolveComponent(ComponentSpecification $componentSpecification,
44
                                     LoggerInterface $logger) {
45
        return new Component($componentSpecification->getName(), [
46
            new ComponentVersion(null, null, null, [
47
                new GitComponentSource($componentSpecification->getExtra('uri'), $componentSpecification->getVersion())
48
            ]),
49
        ], $this);
50
    }
51
52
    /**
53
     * @inheritdoc PackageRepository
54
     */
55
    public function satisfiesVersion($versionSpecification, ComponentVersion $version) {
56
        return true;
57
    }
58
}
59