Passed
Pull Request — master (#9)
by vincent
02:49
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 $data = null;
12
    protected $conf = null;
13
    protected $id   = null;
14
    protected $tmdb = null;
15
16
    /**
17
     * Constructor
18
     * @param \vfalies\tmdb\Tmdb $tmdb
19
     * @param int $item_id
20
     * @param array $options
21
     * @param string $item_name
22
     * @throws \Exception
23
     */
24 71
    public function __construct(Tmdb $tmdb, int $item_id, array $options, string $item_name)
25
    {
26
        try
27
        {
28 71
            $this->id   = (int) $item_id;
29 71
            $this->tmdb = $tmdb;
30 71
            $this->conf = $this->tmdb->getConfiguration();
31 71
            $params     = $this->tmdb->checkOptions($options);
32 71
            $this->data = $this->tmdb->sendRequest(new CurlRequest(), $item_name . '/' . (int) $item_id, null, $params);
33
        }
34 3
        catch (\Exception $ex)
35
        {
36 3
            throw new \Exception($ex->getMessage(), $ex->getCode(), $ex);
37
        }
38 68
    }
39
40
41
}
42