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

Item   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 32
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 2
1
<?php
2
3
namespace vfalies\tmdb\Abstracts;
4
5
use vfalies\tmdb\Tmdb;
6
use vfalies\tmdb\lib\CurlRequest;
7
8
abstract class Item extends Element
9
{
10
11
    protected $id   = null;
12
    protected $tmdb = null;
13
14
    /**
15
     * Constructor
16
     * @param \vfalies\tmdb\Tmdb $tmdb
17
     * @param int $item_id
18
     * @param array $options
19
     * @param string $item_name
20
     * @throws \Exception
21
     */
22 83
    public function __construct(Tmdb $tmdb, int $item_id, array $options, string $item_name)
23
    {
24
        try
25
        {
26 83
            $this->id   = (int) $item_id;
27 83
            $this->tmdb = $tmdb;
28 83
            $this->conf = $this->tmdb->getConfiguration();
29 83
            $params     = $this->tmdb->checkOptions($options);
30 83
            $this->data = $this->tmdb->sendRequest(new CurlRequest(), $item_name . '/' . (int) $item_id, null, $params);
31
        }
32 3
        catch (\Exception $ex)
33
        {
34 3
            throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
35
        }
36 80
    }
37
38
39
}
40