MovieVideos   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 48
ccs 11
cts 11
cp 1
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getVideos() 0 6 3
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-2020
12
 */
13
14
15
namespace VfacTmdb\Items;
16
17
use VfacTmdb\Results;
18
use VfacTmdb\Interfaces\TmdbInterface;
19
20
/**
21
 * Movie Videos class
22
 * @package Tmdb
23
 * @author Vincent Faliès <[email protected]>
24
 * @copyright Copyright (c) 2017-2020
25
 */
26
class MovieVideos
27
{
28
    /**
29
     * Tmdb object
30
     * @var TmdbInterface
31
     */
32
    private $tmdb = null;
33
    /**
34
     * Logger object
35
     * @var \Psr\Log\LoggerInterface
36
     */
37
    protected $logger = null;
38
    /**
39
     * Params
40
     * @var array
41
     */
42
    protected $params = null;
43
    /**
44
     * Data
45
     * @var \stdClass
46
     */
47
    protected $data = null;
48
    /**
49
     * Options array
50
     * @var array
51
     */
52
    protected $options;
53
54
    /**
55
     * Constructor
56
     * @param TmdbInterface $tmdb
57
     * @param int $movie_id
58
     * @param array $options
59
     */
60 27
    public function __construct(TmdbInterface $tmdb, int $movie_id, array $options = array())
61
    {
62 27
        $this->tmdb    = $tmdb;
63 27
        $this->logger  = $tmdb->getLogger();
64 27
        $this->data    = $this->tmdb->getRequest('movie/' . $movie_id . '/videos');
65 27
        $this->options = $options;
66 27
    }
67
68 27
    public function getVideos() : \Generator
69
    {
70 27
        if (!empty($this->data->results)) {
71 27
            foreach ($this->data->results as $r) {
72 27
                $video = new Results\Videos($this->tmdb, $r);
73 27
                yield $video;
74
            }
75
        }
76 3
    }
77
}
78