1<?php
2/**
3 * This file is part of the Tmdb PHP API created by Michael Roterman.
4 *
5 * For the full copyright and license information, please view the LICENSE
6 * file that was distributed with this source code.
7 *
8 * @package Tmdb
9 * @author Michael Roterman <michael@wtfz.net>
10 * @copyright (c) 2013, Michael Roterman
11 * @version 0.0.1
12 */
13namespace Tmdb\Model;
14
15use Tmdb\Model\Filter\ImageFilter;
16use Tmdb\Model\Filter\LanguageFilter;
17
18/**
19 * Class Image
20 * @package Tmdb\Model
21 */
22class Image extends AbstractModel implements ImageFilter, LanguageFilter
23{
24    const FORMAT_POSTER   = 'poster';
25    const FORMAT_BACKDROP = 'backdrop';
26    const FORMAT_PROFILE  = 'profile';
27    const FORMAT_LOGO     = 'logo';
28    const FORMAT_STILL    = 'still';
29
30    private $filePath;
31    private $width;
32    private $height;
33    private $iso6391;
34    private $aspectRatio;
35    private $voteAverage;
36    private $voteCount;
37    private $media;
38
39    protected $id;
40    protected $type;
41
42    public static $properties = [
43        'file_path',
44        'width',
45        'height',
46        'iso_639_1',
47        'aspect_ratio',
48        'vote_average',
49        'vote_count'
50    ];
51
52    public static $formats = [
53        'posters'   => self::FORMAT_POSTER,
54        'backdrops' => self::FORMAT_BACKDROP,
55        'profiles'  => self::FORMAT_PROFILE,
56        'logos'     => self::FORMAT_LOGO,
57        'stills'    => self::FORMAT_STILL
58    ];
59
60    /**
61     * Get the singular type as defined in $_types
62     *
63     * @param $name
64     * @return mixed
65     */
66    public static function getTypeFromCollectionName($name)
67    {
68        if (array_key_exists($name, self::$formats)) {
69            return self::$formats[$name];
70        }
71    }
72
73    /**
74     * @param  float $aspectRatio
75     * @return $this
76     */
77    public function setAspectRatio($aspectRatio)
78    {
79        $this->aspectRatio = (float) $aspectRatio;
80
81        return $this;
82    }
83
84    /**
85     * @return float
86     */
87    public function getAspectRatio()
88    {
89        return $this->aspectRatio;
90    }
91
92    /**
93     * @param  mixed $filePath
94     * @return $this
95     */
96    public function setFilePath($filePath)
97    {
98        $this->filePath = $filePath;
99
100        return $this;
101    }
102
103    /**
104     * @return mixed
105     */
106    public function getFilePath()
107    {
108        return $this->filePath;
109    }
110
111    /**
112     * @param  mixed $height
113     * @return $this
114     */
115    public function setHeight($height)
116    {
117        $this->height = (int) $height;
118
119        return $this;
120    }
121
122    /**
123     * @return integer
124     */
125    public function getHeight()
126    {
127        return $this->height;
128    }
129
130    /**
131     * @param  mixed $iso6391
132     * @return $this
133     */
134    public function setIso6391($iso6391)
135    {
136        $this->iso6391 = $iso6391;
137
138        return $this;
139    }
140
141    /**
142     * @return mixed
143     */
144    public function getIso6391()
145    {
146        return $this->iso6391;
147    }
148
149    /**
150     * @param  float $voteAverage
151     * @return $this
152     */
153    public function setVoteAverage($voteAverage)
154    {
155        $this->voteAverage = (float) $voteAverage;
156
157        return $this;
158    }
159
160    /**
161     * @return float
162     */
163    public function getVoteAverage()
164    {
165        return $this->voteAverage;
166    }
167
168    /**
169     * @param  int   $voteCount
170     * @return $this
171     */
172    public function setVoteCount($voteCount)
173    {
174        $this->voteCount = (int) $voteCount;
175
176        return $this;
177    }
178
179    /**
180     * @return int
181     */
182    public function getVoteCount()
183    {
184        return $this->voteCount;
185    }
186
187    /**
188     * @param  int   $width
189     * @return $this
190     */
191    public function setWidth($width)
192    {
193        $this->width = (int) $width;
194
195        return $this;
196    }
197
198    /**
199     * @return int
200     */
201    public function getWidth()
202    {
203        return $this->width;
204    }
205
206    /**
207     * @param  mixed $media
208     * @return $this
209     */
210    public function setMedia($media)
211    {
212        $this->media = $media;
213
214        return $this;
215    }
216
217    /**
218     * @return mixed
219     */
220    public function getMedia()
221    {
222        return $this->media;
223    }
224
225    /**
226     * Return the file path when casted to string
227     * @return string
228     */
229    public function __toString()
230    {
231        return (string)$this->getFilePath();
232    }
233}
234