Item   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 53
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the Tmdb package.
4
 *
5
 * (c) Vincent Faliès <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author Vincent Faliès <[email protected]>
11
 * @copyright Copyright (c) 2017
12
 */
13
14
15
namespace VfacTmdb\Abstracts;
16
17
use VfacTmdb\Exceptions\TmdbException;
18
use VfacTmdb\Interfaces\TmdbInterface;
19
20
/**
21
 * abstract item class
22
 * @package Tmdb
23
 * @author Vincent Faliès <[email protected]>
24
 * @copyright Copyright (c) 2017
25
 */
26
abstract class Item
27
{
28
    /**
29
     * id
30
     * @var int
31
     */
32
    protected $id = null;
33
    /**
34
     * Tmdb object
35
     * @var TmdbInterface
36
     */
37
    protected $tmdb = null;
38
    /**
39
     * Logger
40
     * @var \Psr\Log\LoggerInterface
41
     */
42
    protected $logger = null;
43
    /**
44
     * Configuration
45
     * @var \stdClass
46
     */
47
    protected $conf = null;
48
    /**
49
     * Params
50
     * @var array
51
     */
52
    protected $params = [];
53
    /**
54
     * Data
55
     * @var \stdClass
56
     */
57
    protected $data = null;
58
59
    /**
60
     * Constructor
61
     * @param TmdbInterface $tmdb
62
     * @param int $item_id
63
     * @param array $options
64
     * @param string $item_name
65
     * @throws \Exception
66
     */
67 825
    public function __construct(TmdbInterface $tmdb, int $item_id, array $options, string $item_name)
68
    {
69
        try {
70 825
            $this->id     = $item_id;
71 825
            $this->tmdb   = $tmdb;
72 825
            $this->logger = $tmdb->getLogger();
73 825
            $this->conf   = $this->tmdb->getConfiguration();
74 825
            $this->tmdb->checkOptionLanguage($options, $this->params);
75
76 825
            $this->data   = $this->tmdb->getRequest($item_name . '/' . (int) $item_id, $this->params);
77 18
        } catch (TmdbException $ex) {
78 3
            throw $ex;
79
        }
80 807
    }
81
}
82