Completed
Pull Request — master (#1)
by Viacheslav
02:50
created

Getter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 11
ccs 0
cts 7
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Swaggest\PhpCodeBuilder\Property;
4
5
6
use Swaggest\PhpCodeBuilder\PhpClassProperty;
7
use Swaggest\PhpCodeBuilder\PhpFlags;
8
use Swaggest\PhpCodeBuilder\PhpFunction;
9
10
class Getter extends PhpFunction
11
{
12
    /**
13
     * Getter constructor.
14
     * @param PhpClassProperty $property
15
     */
16
    public function __construct(PhpClassProperty $property)
17
    {
18
        $name = $property->getNamedVar()->getName();
19
        parent::__construct('get' . ucfirst($name), PhpFlags::VIS_PUBLIC);
20
21
        $this->skipCodeCoverage = true;
22
23
        $this->setResult($property->getNamedVar()->getType());
24
        $this->setBody(
25
            <<<PHP
26
return \$this->{$name};
27
28
PHP
29
30
        );
31
    }
32
}