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

Item   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
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 34
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 $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