PassportServerIntegration::getTokenRepository()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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