ParameterAnnotation::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Retrofit\Annotation;
10
11
use Tebru;
12
use Tebru\AnnotationReader\AbstractAnnotation;
13
14
/**
15
 * Parent class for annotation that have a [parameterName => $parameterName] format
16
 *
17
 * @author Nate Brunette <[email protected]>
18
 */
19
abstract class ParameterAnnotation extends AbstractAnnotation implements ParameterAwareAnnotation
20
{
21
    /**
22
     * An alias for the variable name
23
     *
24
     * @var string $var
25
     */
26
    private $var;
27
28
    /**
29
     * Initialize annotation data
30
     */
31 46
    protected function init(): void
32
    {
33 46
        parent::init();
34
35 46
        $this->var = $this->data['var'] ?? null;
36 46
    }
37
38
    /**
39
     * Get the variable name
40
     *
41
     * @return string
42
     */
43 13
    public function getVariableName(): string
44
    {
45 13
        return $this->var ?? $this->getValue();
46
    }
47
}
48