Line | |
---|
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 | |
---|
10 | include_once(INSTAGRAM_ROOT.'/Collection/CollectionAbstract.php'); |
---|
11 | include_once(INSTAGRAM_ROOT.'/Tag.php'); |
---|
12 | |
---|
13 | |
---|
14 | /** |
---|
15 | * Tag Collection |
---|
16 | * |
---|
17 | * Holds a collection of tags |
---|
18 | */ |
---|
19 | class Instagram_Collection_TagCollection extends Instagram_Collection_CollectionAbstract { |
---|
20 | |
---|
21 | /** |
---|
22 | * Set the collection data |
---|
23 | * |
---|
24 | * @param StdClass $raw_data |
---|
25 | * @access public |
---|
26 | */ |
---|
27 | public function setData( $raw_data ) { |
---|
28 | if ( isset( $raw_data->data ) ) { |
---|
29 | $this->data = $raw_data->data; |
---|
30 | } |
---|
31 | elseif( is_array( $raw_data ) ) { |
---|
32 | $this->data = array_map( create_function( '$t', 'return (object)array( \'name\' => $t );' ), $raw_data ); |
---|
33 | } |
---|
34 | $this->convertData( 'Instagram_Tag' ); |
---|
35 | } |
---|
36 | |
---|
37 | /** |
---|
38 | * Get an array of tag names |
---|
39 | * |
---|
40 | * @return array Returns an array of tags |
---|
41 | * @access public |
---|
42 | */ |
---|
43 | public function toArray() { |
---|
44 | $tags = array(); |
---|
45 | foreach( $this->data as $tag ) { |
---|
46 | $tags[] = $tag->getName(); |
---|
47 | } |
---|
48 | return $tags; |
---|
49 | } |
---|
50 | |
---|
51 | } |
---|
52 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.