Passed
Pull Request — master (#9)
by vincent
02:49
created

Results::__construct()   B

Complexity

Conditions 5
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 7
nc 3
nop 2
crap 5
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 $conf          = null;
14
15
    protected $data = null;
16
17
    /**
18
     * Constructor
19
     * @param \vfalies\tmdb\Tmdb $tmdb
20
     * @param \stdClass $result
21
     * @throws \Exception
22
     */
23 37
    public function __construct(Tmdb $tmdb, \stdClass $result)
24
    {
25
        // Valid input object
26 37
        $properties = get_object_vars($this);
27 37
        foreach (array_keys($properties) as $property)
28
        {
29 37
            if ($property != 'conf' && $property != 'data' && !property_exists($result, $property))
30
            {
31 37
                throw new \Exception('Incorrect input for ' . __CLASS__ . ' object. Property "' . $property . '" not found');
32
            }
33
        }
34
35
        // Configuration
36 37
        $this->conf = $tmdb->getConfiguration();
37 37
        $this->data = $result;
38 37
    }
39
40
}
41