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

Getter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 7
cp 0
rs 10
c 0
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
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
}