PropertyTypeExtractor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setPropertyName() 0 4 1
A execute() 0 9 2
1
<?php
2
3
/**
4
 * This file is part of sensorario/resources repository
5
 *
6
 * (c) Simone Gentili <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sensorario\Resources\Helpers;
13
14
use Sensorario\Resources\Interfaces\Helper;
15
use Sensorario\Resources\Resource;
16
17
final class PropertyTypeExtractor implements Helper
18
{
19
    private $resource;
20
21
    private $propertyName;
22
23 3
    public function __construct(Resource $resource)
24
    {
25 3
        $this->resource = $resource;
26 3
    }
27
28 3
    public function setPropertyName($propertyName)
29
    {
30 3
        $this->propertyName = $propertyName;
31 3
    }
32
33 3
    public function execute()
34
    {
35 3
        $property = $this->resource->get($this->propertyName);
36
37 3
        return is_object($property)
38 1
            ? get_class($property)
39 3
            : gettype($property)
40
        ;
41
    }
42
}
43