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.

Repository   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 103
Duplicated Lines 15.53 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 5
dl 16
loc 103
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A addRange() 8 8 2
A apply() 0 4 1
A remove() 0 4 1
A removeRange() 8 8 2
A removeWhere() 0 4 1
A clear() 0 4 1
A executeQuery() 0 4 1
A newMethodSegment() 0 4 1
A join() 0 6 1
A groupJoin() 0 6 1
A offsetSet() 0 4 1
A offsetUnset() 0 4 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
namespace Pinq;
4
5
use Pinq\Expressions as O;
6
use Pinq\Iterators\IIteratorScheme;
7
8
/**
9
 * The standard repository class, fully implements the repository API
10
 *
11
 * @author Elliot Levin <[email protected]>
12
 */
13
class Repository extends Queryable implements IRepository, Interfaces\IOrderedRepository
14
{
15
    /**
16
     * The repository provider for the current instance
17
     *
18
     * @var Providers\IRepositoryProvider
19
     */
20
    protected $repositoryProvider;
21
22
    public function __construct(
23
            Providers\IRepositoryProvider $provider,
24
            Queries\ISourceInfo $sourceInfo,
25
            O\TraversalExpression $queryExpression = null,
26
            IIteratorScheme $scheme = null
27
    ) {
28
        parent::__construct($provider, $sourceInfo, $queryExpression, $scheme);
29
30
        $this->repositoryProvider = $provider;
31
    }
32
33
    /**
34
     * Executes the supplied operation query expression on the underlying repository provider.
35
     *
36
     * @param O\Expression $expression
37
     *
38
     * @return void
39
     */
40
    private function executeQuery(O\Expression $expression)
41
    {
42
        $this->repositoryProvider->execute($expression);
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     * @return IRepository
48
     */
49
    protected function newMethodSegment($name, array $arguments = [])
50
    {
51
        return $this->repositoryProvider->createRepository($this->newMethod($name, $arguments));
52
    }
53
54
    public function join($values)
55
    {
56
        return new Connectors\JoiningRepository(
57
                $this->repositoryProvider,
58
                $this->newMethod(__FUNCTION__, [$values]));
59
    }
60
61
    public function groupJoin($values)
62
    {
63
        return new Connectors\JoiningRepository(
64
                $this->repositoryProvider,
65
                $this->newMethod(__FUNCTION__, [$values]));
66
    }
67
68 View Code Duplication
    public function addRange($values)
0 ignored issues
show
Duplication introduced by
This method 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...
69
    {
70
        if (!Utilities::isIterable($values)) {
71
            throw PinqException::invalidIterable(__METHOD__, $values);
72
        }
73
74
        $this->executeQuery($this->newMethod(__FUNCTION__, [$values]));
75
    }
76
77
    public function apply(callable $function)
78
    {
79
        $this->executeQuery($this->newMethod(__FUNCTION__, [$function]));
80
    }
81
82
    public function remove($value)
83
    {
84
        $this->executeQuery($this->newMethod(__FUNCTION__, [$value]));
85
    }
86
87 View Code Duplication
    public function removeRange($values)
0 ignored issues
show
Duplication introduced by
This method 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...
88
    {
89
        if (!Utilities::isIterable($values)) {
90
            throw PinqException::invalidIterable(__METHOD__, $values);
91
        }
92
93
        $this->executeQuery($this->newMethod(__FUNCTION__, [$values]));
94
    }
95
96
    public function removeWhere(callable $predicate)
97
    {
98
        $this->executeQuery($this->newMethod(__FUNCTION__, [$predicate]));
99
    }
100
101
    public function clear()
102
    {
103
        $this->executeQuery($this->newMethod(__FUNCTION__));
104
    }
105
106
    public function offsetSet($index, $value)
107
    {
108
        $this->executeQuery($this->newMethod(__FUNCTION__, [$index, $value]));
109
    }
110
111
    public function offsetUnset($index)
112
    {
113
        $this->executeQuery($this->newMethod(__FUNCTION__, [$index]));
114
    }
115
}
116