Passed
Pull Request — master (#41)
by
unknown
04:05
created

Logo::getVoteCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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 39
    public function __construct(TmdbInterface $tmdb, int $id, \stdClass $result)
81
    {
82 39
        $result->logo_id = $result->id;
83 39
        $result->id      = $id;
84 39
        parent::__construct($tmdb, $result);
85
86 36
        $this->id           = $result->id;
87 36
        $this->logo_id      = $result->logo_id;
88 36
        $this->aspect_ratio = $result->aspect_ratio;
89 36
        $this->file_path    = $result->file_path;
90 36
        $this->height       = $result->height;
91 36
        $this->file_type    = $result->file_type;
92 36
        $this->vote_average = $result->vote_average;
93 36
        $this->vote_count   = $result->vote_count;
94 36
        $this->width        = $result->width;
95 36
    }
96
97
    /**
98
     * Id
99
     * @return int
100
     */
101 3
    public function getId() : int
102
    {
103 3
        return $this->id;
104
    }
105
106
    /**
107
     * Aspect ratio
108
     * @return float
109
     */
110 3
    public function getAspectRatio() : float
111
    {
112 3
        return $this->aspect_ratio;
113
    }
114
115
    /**
116
     * Logo file path
117
     * @return string
118
     */
119 9
    public function getFilePath(bool $svg = true) : string
120
    {
121 9
        if ($svg === true && $this->file_type === '.svg') {
122 6
            return substr($this->file_path, 0, -3) . 'svg';
123
        }
124
125 3
        return $this->file_path;
126
    }
127
128
    /**
129
     * Original file type
130
     * @return string
131
     */
132 3
    public function getFileType() : string
133
    {
134 3
        return $this->file_type;
135
    }
136
137
    /**
138
     * Height
139
     * @return int
140
     */
141 3
    public function getHeight() : int
142
    {
143 3
        return $this->height;
144
    }
145
146
    /**
147
     * Id
148
     * @return string
149
     */
150 3
    public function getLogoId() : string
151
    {
152 3
        return $this->logo_id;
153
    }
154
155
    /**
156
     * Vote average
157
     * @return float
158
     */
159 3
    public function getVoteAverage() : float
160
    {
161 3
        return $this->vote_average;
162
    }
163
164
    /**
165
     * Vote count
166
     * @return int
167
     */
168 3
    public function getVoteCount() : int
169
    {
170 3
        return $this->vote_count;
171
    }
172
173
    /**
174
     * Width
175
     * @return int
176
     */
177 3
    public function getWidth() : int
178
    {
179 3
        return $this->width;
180
    }
181
}
182