Completed
Push — master ( 7c3a00...4fd5ad )
by Neomerx
04:42
created

PassportServerIntegration::getScopeRepository()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php namespace Limoncello\Passport\Adaptors\MySql;
2
3
/**
4
 * Copyright 2015-2017 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Limoncello\Passport\Contracts\Entities\TokenInterface;
20
use Limoncello\Passport\Contracts\Repositories\ClientRepositoryInterface;
21
use Limoncello\Passport\Contracts\Repositories\RedirectUriRepositoryInterface;
22
use Limoncello\Passport\Contracts\Repositories\ScopeRepositoryInterface;
23
use Limoncello\Passport\Contracts\Repositories\TokenRepositoryInterface;
24
use Limoncello\Passport\Integration\BasePassportServerIntegration;
25
26
/**
27
 * @package Limoncello\Passport
28
 */
29 View Code Duplication
class PassportServerIntegration extends BasePassportServerIntegration
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...
30
{
31
    /**
32
     * @var ClientRepositoryInterface|null
33
     */
34
    private $clientRepo;
35
36
    /**
37
     * @var TokenRepositoryInterface|null
38
     */
39
    private $tokenRepo;
40
41
    /**
42
     * @var ScopeRepositoryInterface|null
43
     */
44
    private $scopeRepo;
45
46
    /**
47
     * @var RedirectUriRepositoryInterface|null
48
     */
49
    private $uriRepo;
50
51
    /**
52
     * @inheritdoc
53
     */
54
    public function getClientRepository(): ClientRepositoryInterface
55
    {
56
        if ($this->clientRepo === null) {
57
            $this->clientRepo = new ClientRepository($this->getConnection(), $this->getDatabaseScheme());
58
        }
59
60
        return $this->clientRepo;
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66
    public function getScopeRepository(): ScopeRepositoryInterface
67
    {
68
        if ($this->scopeRepo === null) {
69
            $this->scopeRepo = new ScopeRepository($this->getConnection(), $this->getDatabaseScheme());
70
        }
71
72
        return $this->scopeRepo;
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78
    public function getRedirectUriRepository(): RedirectUriRepositoryInterface
79
    {
80
        if ($this->uriRepo === null) {
81
            $this->uriRepo = new RedirectUriRepository($this->getConnection(), $this->getDatabaseScheme());
82
        }
83
84
        return $this->uriRepo;
85
    }
86
87
    /**
88
     * @inheritdoc
89
     */
90
    public function getTokenRepository(): TokenRepositoryInterface
91
    {
92
        if ($this->tokenRepo === null) {
93
            $this->tokenRepo = new TokenRepository($this->getConnection(), $this->getDatabaseScheme());
94
        }
95
96
        return $this->tokenRepo;
97
    }
98
99
    /**
100
     * @inheritdoc
101
     */
102
    public function createTokenInstance(): TokenInterface
103
    {
104
        $token = new Token();
105
106
        return $token;
107
    }
108
}
109