Completed
Push — master ( b6f561...db9bd8 )
by Neomerx
03:16
created

Attribute::getNameInScheme()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php namespace Limoncello\Flute\Http\Query;
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\Flute\Contracts\Http\Query\AttributeInterface;
20
use Limoncello\Flute\Contracts\Schema\SchemaInterface;
21
22
/**
23
 * @package Limoncello\Flute
24
 */
25
class Attribute implements AttributeInterface
26
{
27
    /**
28
     * @var string
29
     */
30
    private $nameInScheme;
31
32
    /**
33
     * @var string
34
     */
35
    private $nameInModel;
36
37
    /**
38
     * @var SchemaInterface
39
     */
40
    private $scheme;
41
42
    /**
43
     * @param string          $nameInScheme
44
     * @param SchemaInterface $scheme
45
     */
46 9
    public function __construct(string $nameInScheme, SchemaInterface $scheme)
47
    {
48 9
        $this->nameInScheme = $nameInScheme;
49 9
        $this->scheme       = $scheme;
50
51 9
        $this->nameInModel = null;
52
    }
53
54
    /**
55
     * @return string
56
     */
57 9
    public function getNameInScheme(): string
58
    {
59 9
        return $this->nameInScheme;
60
    }
61
62
    /**
63
     * @return SchemaInterface
64
     */
65 9
    public function getScheme(): SchemaInterface
66
    {
67 9
        return $this->scheme;
68
    }
69
70
    /**
71
     * @return string
72
     */
73 7
    public function getNameInModel():string
74
    {
75 7
        if ($this->nameInModel === null) {
76 7
            $this->nameInModel = $this->getScheme()->getAttributeMapping($this->getNameInScheme());
77
        }
78
79 7
        return $this->nameInModel;
80
    }
81
}
82