Passed
Push — master ( d37a32...6985b0 )
by vincent
39s
created

Results   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 32
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 4
1
<?php
2
3
namespace vfalies\tmdb\Abstracts;
4
5
use vfalies\tmdb\Tmdb;
6
7
abstract class Results extends Element implements \vfalies\tmdb\Interfaces\ResultsInterface
8
{
9
10
    protected $id                 = null;
11
    protected $poster_path        = null;
12
    protected $backdrop_path      = null;
13
    protected $property_blacklist = ['property_blacklist', 'conf', 'data'];
14
15
    /**
16
     * Constructor
17
     * @param \vfalies\tmdb\Tmdb $tmdb
18
     * @param \stdClass $result
19
     * @throws \Exception
20
     */
21 37
    public function __construct(Tmdb $tmdb, \stdClass $result)
22
    {
23
        // Valid input object
24 37
        $properties = get_object_vars($this);
25 37
        foreach (array_keys($properties) as $property)
26
        {
27 37
            if ( ! in_array($property, $this->property_blacklist) && !property_exists($result, $property))
28
            {
29 37
                throw new \Exception('Incorrect input for ' . __CLASS__ . ' object. Property "' . $property . '" not found');
30
            }
31
        }
32
33
        // Configuration
34 37
        $this->conf = $tmdb->getConfiguration();
35 37
        $this->data = $result;
36 37
    }
37
38
}
39