Scope   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 2
dl 0
loc 88
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getIdentifier() 0 4 1
A setIdentifier() 0 6 1
A getDescription() 0 4 1
A setDescription() 0 6 1
A setCreatedAt() 0 7 1
A setUpdatedAt() 0 7 1
1
<?php declare(strict_types=1);
2
3
namespace Limoncello\Passport\Entities;
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 DateTimeInterface;
22
use Limoncello\Passport\Contracts\Entities\ScopeInterface;
23
24
/**
25
 * @package Limoncello\Passport
26
 */
27
abstract class Scope extends DatabaseItem implements ScopeInterface
28
{
29
    /** Field name */
30
    const FIELD_ID = 'id_scope';
31
32
    /** Field name */
33
    const FIELD_DESCRIPTION = 'description';
34
35
    /**
36
     * @var string|null
37
     */
38
    private $identifierField;
39
40
    /**
41
     * @var string|null
42
     */
43
    private $descriptionField;
44
45
    /**
46
     * Constructor.
47
     */
48 22
    public function __construct()
49
    {
50 22
        if ($this->hasDynamicProperty(static::FIELD_ID) === true) {
51
            $this
52 1
                ->setIdentifier($this->{static::FIELD_ID})
53 1
                ->setDescription($this->{static::FIELD_DESCRIPTION});
54
        }
55
    }
56
57
    /**
58
     * @inheritdoc
59
     */
60 21
    public function getIdentifier(): ?string
61
    {
62 21
        return $this->identifierField;
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68 20
    public function setIdentifier(string $identifier): ScopeInterface
69
    {
70 20
        $this->identifierField = $identifier;
71
72 20
        return $this;
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78 21
    public function getDescription(): ?string
79
    {
80 21
        return $this->descriptionField;
81
    }
82
83
    /**
84
     * @inheritdoc
85
     */
86 2
    public function setDescription(string $description = null): ScopeInterface
87
    {
88 2
        $this->descriptionField = $description;
89
90 2
        return $this;
91
    }
92
93
    /**
94
     * @inheritdoc
95
     */
96 19
    public function setCreatedAt(DateTimeInterface $createdAt): ScopeInterface
97
    {
98
        /** @var ScopeInterface $self */
99 19
        $self = $this->setCreatedAtImpl($createdAt);
100
101 19
        return $self;
102
    }
103
104
    /**
105
     * @inheritdoc
106
     */
107 1
    public function setUpdatedAt(DateTimeInterface $createdAt): ScopeInterface
108
    {
109
        /** @var ScopeInterface $self */
110 1
        $self = $this->setUpdatedAtImpl($createdAt);
111
112 1
        return $self;
113
    }
114
}
115