Getter::__construct()   A
last analyzed

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 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
nc 1
nop 1
dl 0
loc 11
ccs 0
cts 7
cp 0
crap 2
rs 10
c 2
b 0
f 0
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
}