Version 1
[yaffs-website] / vendor / php-instagram-api / php-instagram-api / Instagram / Collection / TagCollection.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\Collection;
10
11 /**
12  * Tag Collection
13  *
14  * Holds a collection of tags
15  */
16 class TagCollection extends \Instagram\Collection\CollectionAbstract {
17
18     /**
19      * Set the collection data
20      *
21      * @param StdClass $raw_data
22      * @access public
23      */
24     public function setData( $raw_data ) {
25         if ( isset( $raw_data->data ) ) {
26             $this->data = $raw_data->data;
27         }
28         elseif( is_array( $raw_data ) ) {
29             $this->data = array_map( function( $t ){ return (object)array( 'name' => $t ); }, $raw_data );
30         }
31         $this->convertData( '\Instagram\Tag' );
32     }
33
34     /**
35      * Get an array of tag names
36      * 
37      * @return array Returns an array of tags
38      * @access public
39      */
40     public function toArray() {
41         $tags = array();
42         foreach( $this->data as $tag ) {
43             $tags[] = $tag->getName();
44         }
45         return $tags;
46     }
47
48 }