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.

OperationQuery   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 37
loc 37
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getOperation() 4 4 1
A __construct() 5 5 1
A update() 8 8 3
A updateOperation() 4 4 1
A withScope() 4 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\Queries;
4
5
/**
6
 * Implementation of the IOperationQuery
7
 *
8
 * @author Elliot Levin <[email protected]>
9
 */
10 View Code Duplication
class OperationQuery extends Query implements IOperationQuery
11
{
12
    /**
13
     * @var IOperation
14
     */
15
    private $operation;
16
17
    public function __construct(IScope $scope, IOperation $operation)
18
    {
19
        parent::__construct($scope, $operation->getParameters());
20
        $this->operation = $operation;
21
    }
22
23
    public function getOperation()
24
    {
25
        return $this->operation;
26
    }
27
28
    public function update(IScope $scope, IOperation $operation)
29
    {
30
        if ($this->scope === $scope && $this->operation === $operation) {
31
            return $this;
32
        }
33
34
        return new self($scope, $operation);
35
    }
36
37
    public function updateOperation(IOperation $operation)
38
    {
39
        return $this->update($this->scope, $operation);
40
    }
41
42
    protected function withScope(IScope $scope)
43
    {
44
        return $this->update($scope, $this->operation);
45
    }
46
}
47