Test Failed
Pull Request — master (#41)
by
unknown
07:06
created

Logo   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 161
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 161
c 0
b 0
f 0
wmc 12
lcom 1
cbo 1
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 1
A getId() 0 4 1
A getAspectRatio() 0 4 1
A getFilePath() 0 4 1
A getFileType() 0 4 1
A getHeight() 0 4 1
A getLogoId() 0 4 1
A getVoteAverage() 0 4 1
A getVoteCount() 0 4 1
A getWidth() 0 4 1
A getBestFilePath() 0 4 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-2020
12
 */
13
14
15
namespace VfacTmdb\Results;
16
17
use VfacTmdb\Abstracts\Results;
18
use VfacTmdb\Interfaces\TmdbInterface;
19
20
/**
21
 * Class to manipulate a logo result
22
 * @package Tmdb
23
 * @author Steve Richter <[email protected]>
24
 * @copyright Copyright (c) 2017-2020
25
 */
26
class Logo extends Results
27
{
28
    /**
29
     * Id
30
     * @var int
31
     */
32
    protected $id;
33
    /**
34
     * Id
35
     * @var string
36
     */
37
    protected $logo_id;
38
    /**
39
     * Aspect ratio
40
     * @var float
41
     */
42
    protected $aspect_ratio;
43
    /**
44
     * Logo file path
45
     * @var string
46
     */
47
    protected $file_path;
48
    /**
49
     * Height
50
     * @var int
51
     */
52
    protected $height;
53
    /**
54
     * Original file type
55
     * @var string
56
     */
57
    protected $file_type;
58
    /**
59
     * Vote Average
60
     * @var float
61
     */
62
    protected $vote_average;
63
    /**
64
     * Vote count
65
     * @var int
66
     */
67
    protected $vote_count;
68
    /**
69
     * Width
70
     * @var int
71
     */
72
    protected $width;
73
74
    /**
75
     * Constructor
76
     * @param TmdbInterface $tmdb
77
     * @param int $id
78
     * @param \stdClass $result
79
     */
80
    public function __construct(TmdbInterface $tmdb, int $id, \stdClass $result)
81
    {
82
        $result->logo_id = $result->id;
83
        $result->id      = $id;
84
        parent::__construct($tmdb, $result);
85
86
        $this->id           = $result->id;
87
        $this->logo_id      = $result->logo_id;
88
        $this->aspect_ratio = $result->aspect_ratio;
89
        $this->file_path    = $result->file_path;
90
        $this->height       = $result->height;
91
        $this->file_type    = $result->file_type;
92
        $this->vote_average = $result->vote_average;
93
        $this->vote_count   = $result->vote_count;
94
        $this->width        = $result->width;
95
    }
96
97
    /**
98
     * Id
99
     * @return int
100
     */
101
    public function getId() : int
102
    {
103
        return $this->id;
104
    }
105
106
    /**
107
     * Aspect ratio
108
     * @return float
109
     */
110
    public function getAspectRatio() : float
111
    {
112
        return $this->aspect_ratio;
113
    }
114
115
    /**
116
     * Logo file path
117
     * @return string
118
     */
119
    public function getFilePath() : string
120
    {
121
        return $this->file_path;
122
    }
123
124
    /**
125
     * Original file type
126
     * @return string
127
     */
128
    public function getFileType() : string
129
    {
130
        return $this->file_type;
131
    }
132
133
    /**
134
     * Height
135
     * @return int
136
     */
137
    public function getHeight() : int
138
    {
139
        return $this->height;
140
    }
141
142
    /**
143
     * Id
144
     * @return string
145
     */
146
    public function getLogoId() : string
147
    {
148
        return $this->logo_id;
149
    }
150
151
    /**
152
     * Vote average
153
     * @return float
154
     */
155
    public function getVoteAverage() : float
156
    {
157
        return $this->vote_average;
158
    }
159
160
    /**
161
     * Vote count
162
     * @return int
163
     */
164
    public function getVoteCount() : int
165
    {
166
        return $this->vote_count;
167
    }
168
169
    /**
170
     * Width
171
     * @return int
172
     */
173
    public function getWidth() : int
174
    {
175
        return $this->width;
176
    }
177
178
    /**
179
     * Best logo file path
180
     * @return string
181
     */
182
    public function getBestFilePath() : string
183
    {
184
        return $this->file_type === ".svg" ? substr($this->file_path, 0, -3) . 'svg' : $this->file_path;
185
    }
186
}
187