Getter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 17
ccs 0
cts 7
cp 0
rs 10
c 2
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
1
<?php
2
3
namespace Swaggest\PhpCodeBuilder\Property;
4
5
use Swaggest\PhpCodeBuilder\PhpClassProperty;
6
use Swaggest\PhpCodeBuilder\PhpFlags;
7
use Swaggest\PhpCodeBuilder\PhpFunction;
8
9
class Getter extends PhpFunction
10
{
11
    /**
12
     * Getter constructor.
13
     * @param PhpClassProperty $property
14
     */
15
    public function __construct(PhpClassProperty $property)
16
    {
17
        $name = $property->getNamedVar()->getName();
18
        parent::__construct('get' . ucfirst($name), PhpFlags::VIS_PUBLIC);
19
20
        $this->skipCodeCoverage = true;
21
22
        $this->setResult($property->getNamedVar()->getType());
23
        $this->setBody(
24
            <<<PHP
25
return \$this->{$name};
26
27
PHP
28
29
        );
30
    }
31
}