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

Results   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 16 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
14
    /**
15
     * Constructor
16
     * @param \vfalies\tmdb\Tmdb $tmdb
17
     * @param \stdClass $result
18
     * @throws \Exception
19
     */
20 37
    public function __construct(Tmdb $tmdb, \stdClass $result)
21
    {
22
        // Valid input object
23 37
        $properties = get_object_vars($this);
24 37
        foreach (array_keys($properties) as $property)
25
        {
26 37
            if ($property != 'conf' && $property != 'data' && !property_exists($result, $property))
27
            {
28 37
                throw new \Exception('Incorrect input for ' . __CLASS__ . ' object. Property "' . $property . '" not found');
29
            }
30
        }
31
32
        // Configuration
33 37
        $this->conf = $tmdb->getConfiguration();
34 37
        $this->data = $result;
35 37
    }
36
37
}
38