Completed
Pull Request — master (#29)
by vincent
02:44
created

TVEpisodeTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCrew() 0 13 3
1
<?php
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 vfalies\tmdb\Traits;
16
17
use vfalies\tmdb\Results\Crew;
18
19
/**
20
 * TV Episode trait
21
 * @package Tmdb
22
 * @author Vincent Faliès <[email protected]>
23
 * @copyright Copyright (c) 2017
24
 */
25
trait TVEpisodeTrait
26
{
27
    /**
28
     * Get crew of TV Episode
29
     */
30 9
    public function getCrew()
31
    {
32 9
        if (!empty($this->data->crew))
33
        {
34 9
            foreach ($this->data->crew as $crew)
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...
35
            {
36 9
                $crew->gender = null;
37
38 9
                $return = new Crew($this->tmdb, $crew);
1 ignored issue
show
Bug introduced by
The property tmdb 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...
39 9
                yield $return;
40
            }
41
        }
42 2
    }
43
44
}
45