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

Item::__construct()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 4
nop 4
crap 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