Passed
Branch release/1.5.0 (0ec91b)
by vincent
02:45
created

MovieCredit::getCast()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 0
crap 3
1
<?php
2
3
namespace vfalies\tmdb\Items;
4
5
use vfalies\tmdb\Abstracts\Item;
6
use vfalies\tmdb\Tmdb;
7
use vfalies\tmdb\Results\Crew;
8
use vfalies\tmdb\Results\Cast;
9
10
class MovieCredit extends Item
11
{
12
    protected $crew;
13
14
    /**
15
     * Constructor
16
     * @param \vfalies\tmdb\Tmdb $tmdb
17
     * @param int $movie_id
18
     * @param array $options
19
     */
20 10
    public function __construct(Tmdb $tmdb, $movie_id, array $options = array())
21
    {
22 10
        parent::__construct($tmdb, '/credits', $options, 'movie/'.$movie_id);
23 10
    }
24
25 1
    public function getCrew()
26
    {
27 1
        if (!empty($this->data->crew))
28
        {
29 1
            foreach ($this->data->crew as $c)
1 ignored issue
show
Bug introduced by
The property data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
30
            {
31 1
                $crew = new Crew($this->tmdb, $c);
32 1
                yield $crew;
33
            }
34
        }
35 1
    }
36
37 9
    public function getCast()
38
    {
39 9
        if (!empty($this->data->cast))
40
        {
41 9
            foreach ($this->data->cast as $c)
42
            {
43 9
                $cast = new Cast($this->tmdb, $c);
44 9
                yield $cast;
45
            }
46
        }
47 1
    }
48
49
}