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.

RepositoryProvider::createRepository()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Pinq\Providers;
4
5
use Pinq\Expressions as O;
6
use Pinq\Queries\Builders;
7
use Pinq\Queries;
8
use Pinq\Repository;
9
10
/**
11
 * Base class for the repository provider.
12
 *
13
 * @author Elliot Levin <[email protected]>
14
 */
15
abstract class RepositoryProvider extends ProviderBase implements IRepositoryProvider
16
{
17
    /**
18
     * @var Configuration\IRepositoryConfiguration
19
     */
20
    protected $configuration;
21
22
    /**
23
     * @var IQueryProvider
24
     */
25
    protected $queryProvider;
26
27
    /**
28
     * @var Builders\IOperationQueryBuilder
29
     */
30
    protected $operationQueryBuilder;
31
32
    public function __construct(
33
            Queries\ISourceInfo $sourceInfo,
34
            IQueryProvider $queryProvider,
35
            Configuration\IRepositoryConfiguration $configuration = null
36
    ) {
37
        parent::__construct($sourceInfo, $configuration ?: new Configuration\DefaultRepositoryConfiguration());
38
39
        $this->queryProvider         = $queryProvider;
40
        $this->queryResultCollection = $queryProvider->getQueryResultCollection();
41
        $this->operationQueryBuilder = $this->configuration->getOperationQueryBuilder();
42
    }
43
44
    final public function getQueryProvider()
45
    {
46
        return $this->queryProvider;
47
    }
48
49
    final public function getQueryResultCollection()
50
    {
51
        return $this->queryResultCollection;
52
    }
53
54
    final public function createQueryable(O\TraversalExpression $scopeExpression = null)
55
    {
56
        return $this->queryProvider->createQueryable($scopeExpression);
57
    }
58
59
    public function createRepository(O\TraversalExpression $scopeExpression = null)
60
    {
61
        return new Repository($this, $this->sourceInfo, $scopeExpression, $this->scheme);
62
    }
63
64
    final public function load(O\Expression $requestExpression)
65
    {
66
        return $this->queryProvider->load($requestExpression);
67
    }
68
69
    public function execute(O\Expression $operationExpression)
70
    {
71
        $this->executeOperationExpression($operationExpression);
72
        if ($this->queryResultCollection !== null) {
73
            $this->queryResultCollection->clearResults();
74
        }
75
    }
76
77 View Code Duplication
    protected function executeOperationExpression(O\Expression $operationExpression)
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...
78
    {
79
        $resolution = $this->operationQueryBuilder->resolveOperation($operationExpression);
80
        $queryHash  = $resolution->getHash();
81
        $query      = $this->queryCache->tryGet($queryHash);
82
83
        if (!($query instanceof Queries\IOperationQuery)) {
84
            $query = $this->operationQueryBuilder->parseOperation($operationExpression);
85
            $this->queryCache->save($queryHash, $query);
86
        }
87
88
        $resolvedParameters = $query->getParameters()->resolve($resolution);
89
90
        $this->executeOperation($query, $resolvedParameters);
91
    }
92
93
    /**
94
     * @param \Pinq\Queries\IOperationQuery            $operation
95
     * @param \Pinq\Queries\IResolvedParameterRegistry $resolvedParameters
96
     *
97
     * @return void
98
     */
99
    abstract protected function executeOperation(
100
            Queries\IOperationQuery $operation,
101
            Queries\IResolvedParameterRegistry $resolvedParameters
102
    );
103
}
104