AdditionalPropertiesGetter   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 11
ccs 5
cts 5
cp 1
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
1
<?php
2
3
namespace Swaggest\PhpCodeBuilder\Property;
4
5
6
use Swaggest\PhpCodeBuilder\PhpAnyType;
7
use Swaggest\PhpCodeBuilder\PhpFlags;
8
use Swaggest\PhpCodeBuilder\PhpFunction;
9
use Swaggest\PhpCodeBuilder\Types\ArrayOf;
10
11
class AdditionalPropertiesGetter extends PhpFunction
12
{
13 2
    public function __construct(PhpAnyType $type)
14
    {
15 2
        parent::__construct('getAdditionalPropertyValues', PhpFlags::VIS_PUBLIC);
16
17 2
        $this->skipCodeCoverage = true;
18
19 2
        $this->setResult(new ArrayOf($type));
20 2
        $this->setBody(
21
            <<<'PHP'
22 2
$result = array();
23
if (!$names = $this->getAdditionalPropertyNames()) {
24
    return $result;
25
}
26
foreach ($names as $name) {
27
    $result[$name] = $this->$name;
28
}
29
return $result;
30
31
PHP
32
        );
33
    }
34
}