Completed
Pull Request — master (#30)
by vincent
03:53
created

Item   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 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 233
    public function __construct(TmdbInterface $tmdb, int $item_id, array $options, string $item_name)
68
    {
69
        try {
70 233
            $this->id     = $item_id;
71 233
            $this->tmdb   = $tmdb;
72 233
            $this->logger = $tmdb->getLogger();
73 233
            $this->conf   = $this->tmdb->getConfiguration();
74 233
            $this->tmdb->checkOptionLanguage($options, $this->params);
75
76 233
            $this->data   = $this->tmdb->getRequest($item_name . '/' . (int) $item_id, $this->params);
77 5
        } catch (TmdbException $ex) {
78 1
            throw $ex;
79
        }
80 228
    }
81
}
82