ParameterAnnotation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 29
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 1
A getVariableName() 0 4 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