Passed
Pull Request — master (#17)
by
unknown
04:11
created

TVSeason   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 1
dl 0
loc 45
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getId() 0 4 1
A getReleaseDate() 0 4 1
A getEpisodeCount() 0 4 1
A getSeasonNumber() 0 4 1
1
<?php
2
3
namespace vfalies\tmdb\Results;
4
5
use vfalies\tmdb\Abstracts\Results;
6
use vfalies\tmdb\Tmdb;
7
use vfalies\tmdb\Interfaces\Results\TVSeasonResultsInterface;
8
9
class TVSeason extends Results implements TVSeasonResultsInterface
10
{
11
12
    protected $episode_count = 0;
13
    protected $season_number = 0;
14
    protected $poster_path   = null;
15
16
    /**
17
     * Constructor
18
     * @param \vfalies\tmdb\Tmdb $tmdb
19
     * @param \stdClass $result
20
     * @throws \Exception
21
     */
22 5
    public function __construct(Tmdb $tmdb, \stdClass $result)
23
    {
24 5
        parent::__construct($tmdb, $result);
25
26
        // Populate data
27 5
        $this->id            = $this->data->id;
28 5
        $this->release_date  = $this->data->air_date;
0 ignored issues
show
Bug introduced by
The property release_date 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...
29 5
        $this->episode_count = $this->data->episode_count;
30 5
        $this->poster_path   = $this->data->poster_path;
31 5
        $this->season_number = $this->data->season_number;
32 5
    }
33
34 1
    public function getId(): int
35
    {
36 1
        return $this->id;
37
    }
38
39 1
    public function getReleaseDate(): string
40
    {
41 1
        return $this->release_date;
42
    }
43
44 1
    public function getEpisodeCount(): int
45
    {
46 1
        return (int) $this->episode_count;
47
    }
48
49 1
    public function getSeasonNumber(): int
50
    {
51 1
        return (int) $this->season_number;
52
    }
53
}
54