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

MovieCredit   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 3
dl 0
loc 40
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCrew() 0 11 3
A getCast() 0 11 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
}