Version 1
[yaffs-website] / vendor / php-instagram-api / php-instagram-api / Instagram / Location.php
1 <?php
2
3 /**
4 * Instagram PHP
5 * @author Galen Grover <galenjr@gmail.com>
6 * @license http://opensource.org/licenses/mit-license.php The MIT License
7 */
8
9 namespace Instagram;
10
11 use \Instagram\Collection\MediaCollection;
12
13 /**
14  * Location class
15  *
16  * Some media has a location associated to it. This location will have an ID and a name.
17  * Some media has no location associated, but has a lat/lng. These location objects will return null or '' for certain method calls
18  *
19  * @see \Instagram\Instagram->getCurrentUser()
20  * {@link https://github.com/galen/PHP-Instagram-API/blob/master/Examples/location.php}
21  * {@link http://galengrover.com/projects/instagram/?example=location.php}
22  */
23 class Location extends \Instagram\Core\BaseObjectAbstract {
24
25     /**
26      * Get location media
27      *
28      * Retrieve the recent media posted to a given location
29      *
30      * This can be paginated with the next_max_id param obtained from MediaCollection->getNext()
31      *
32      * @param array $params Optional params to pass to the endpoint
33      * @return \Instagram\Collection\MediaCollection
34      * @access public
35      */
36     public function getMedia( array $params = null ) {
37         return new MediaCollection( $this->proxy->getLocationMedia( $this->getApiId(), $params ), $this->proxy );
38     }
39
40     /**
41      * Get location ID
42      *
43      * @return string|null
44      * @access public
45      */
46     public function getId() {
47         return isset( $this->data->id ) ? $this->data->id : null;
48     }
49
50     /**
51      * Get location name
52      *
53      * @return string|null
54      * @access public
55      */
56     public function getName() {
57         return isset( $this->data->name ) ? $this->data->name : null;
58     }
59
60     /**
61      * Get location longitude
62      *
63      * Get the longitude of the location
64      *
65      * @return string|null
66      * @access public
67      */
68     public function getLat() {
69         return isset( $this->data->latitude ) && is_float( $this->data->latitude ) ? $this->data->latitude : null;
70     }
71
72     /**
73      * Get location latitude
74      *
75      * Get the latitude of the location
76      *
77      * @return string|null
78      * @access public
79      */
80     public function getLng() {
81         return isset( $this->data->longitude ) && is_float( $this->data->longitude ) ? $this->data->longitude : null;
82     }
83
84     /**
85      * Magic toString method
86      *
87      * Returns the location's name
88      *
89      * @return string
90      * @access public
91      */
92     public function __toString() {
93         return $this->getName() ? $this->getName() : '';
94     }
95
96 }