Passed
Branch account (ed4c74)
by vincent
02:20
created

TVItem::getPostersGeneric()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 2
crap 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\Items;
16
17
use VfacTmdb\Results;
18
use VfacTmdb\Abstracts\Item;
19
use VfacTmdb\Traits\ElementTrait;
20
21
/**
22
 * abstract TV item class
23
 * @package Tmdb
24
 * @author Vincent Faliès <[email protected]>
25
 * @copyright Copyright (c) 2017
26
 */
27
abstract class TVItem extends Item
28
{
29
    use ElementTrait;
30
31
    /**
32
     * Image posters
33
     * @param string $url api url
34
     * @param string $key json key
35
     * @return \Generator|Results\Image
36
     */
37 2
    public function getPostersGeneric(string $url, string $key) : \Generator
38
    {
39 2
        $data = $this->tmdb->getRequest($url, $this->params);
40
41 2
        foreach ($data->$key as $b) {
42 2
            $image = new Results\Image($this->tmdb, $this->id, $b);
43 2
            yield $image;
44
        }
45 2
    }
46
}
47