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\Collection;
14
15use Tmdb\Model\Common\GenericCollection;
16use Tmdb\Model\Timezone\CountryTimezone;
17
18/**
19 * Class Timezones
20 * @package Tmdb\Model\Collection
21 */
22class Timezones extends GenericCollection
23{
24    /**
25     * Returns all countries with timezones
26     *
27     * @return array
28     */
29    public function getCountries()
30    {
31        return $this->data;
32    }
33
34    /**
35     * Retrieve a country from the collection
36     *
37     * @param $id
38     * @return CountryTimezone|null
39     */
40    public function getCountry($id)
41    {
42        foreach ($this->data as $country) {
43            if (strtoupper($id) == (string) $country) {
44                return $country;
45            }
46        }
47
48        return null;
49    }
50
51    /**
52     * Add a timezone to the collection
53     *
54     * @param CountryTimezone $country
55     */
56    public function addCountry($country)
57    {
58        $this->data[] = $country;
59    }
60}
61