Setter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 18
c 2
b 0
f 0
dl 0
loc 35
ccs 12
cts 12
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 28 2
1
<?php
2
3
namespace Swaggest\PhpCodeBuilder\Property;
4
5
use Swaggest\PhpCodeBuilder\PhpClassProperty;
6
use Swaggest\PhpCodeBuilder\PhpDocType;
7
use Swaggest\PhpCodeBuilder\PhpFlags;
8
use Swaggest\PhpCodeBuilder\PhpFunction;
9
10
class Setter extends PhpFunction
11
{
12
    /**
13
     * Getter constructor.
14
     * @param PhpClassProperty $property
15
     * @param bool $fluent
16
     */
17 5
    public function __construct(PhpClassProperty $property, $fluent = true)
18
    {
19 5
        $name = $property->getNamedVar()->getName();
20 5
        parent::__construct(
21 5
            'set' . ucfirst($name),
22 5
            PhpFlags::VIS_PUBLIC
23
        );
24
25 5
        $this->skipCodeCoverage = true;
26
        $this->outputArgumentsWithDefaults = false;
27 5
28
        $this->addArgument($property->getNamedVar());
29
30 5
        $body = <<<PHP
31
\$this->{$name} = \${$name};
32
33
PHP;
34 5
35 5
        if ($fluent) {
36
            $this->setResult(PhpDocType::thisType());
37 5
            $body .= <<<PHP
38
return \$this;
39
40
PHP;
41
42
        }
43 5
44
        $this->setBody($body);
45 5
46
    }
47
}