source: extensions/instagram2piwigo/include/Instagram/Core/BaseObjectAbstract.php @ 19561

Last change on this file since 19561 was 19561, checked in by mistic100, 11 years ago

first commit

File size: 2.4 KB
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
10include_once(INSTAGRAM_ROOT.'/Core/Proxy.php');
11
12
13/**
14 * Base object that all objects extend from
15 *
16 * Provides core functionality
17 */
18abstract class Instagram_Core_BaseObjectAbstract {
19
20    /**
21     * Object data
22     *
23     * @var StdClass
24     * @access protected
25     */
26    protected $data;
27
28    /**
29     * Proxy object that does all the API heavy lifting
30     *
31     * @var Instagram_Core_Proxy
32     * @access protected
33     */
34    protected $proxy = null;
35
36    /**
37     * Get the ID returned from the API
38     *
39     * @return string
40     * @access public
41     */
42    public function getId() {
43        return $this->data->id;
44    }
45
46    /**
47     * Get the API ID
48     *
49     * Some API objects don't have IDs (tags, some locations )
50     * Those objects define their own getId() methods to return a psuedo ID
51     * Tags = tag name, ID-less locations return null
52     *
53     * @return string Returns the ID
54     * @access public
55     */
56    public function getApiId() {
57        return $this->getId();
58    }
59
60    /**
61     * Constructor
62     *
63     * @param StdClass $data Object's data
64     * @param Instagram_Core_Proxy $proxy Object's proxy
65     * @access public
66     */
67    public function __construct( $data, Instagram_Core_Proxy $proxy = null ) {
68        $this->setData( $data );
69        $this->proxy = $proxy;
70    }
71
72    /**
73     * Set the object's data
74     *
75     * @param StdClass $data Object data
76     * @access public
77     */
78    public function setData( $data ) {
79        $this->data = $data;
80    }
81
82    /**
83     * Get the object's data
84     *
85     * @return Stdclass Returns the object's data
86     * @access public
87     */
88    public function getData() {
89        return $this->data;
90    }
91
92    /**
93     * Magic method to get data
94     *
95     * This may be removed in future versions
96     *
97     * @param string $var Variable ot get from the data
98     * @return mixed Returns the variable or null
99     * @access public
100     */
101    public function __get( $var ) {
102        return isset( $this->data->$var ) ? $this->data->$var : null;
103    }
104
105    /**
106     * Set the object's proxy
107     *
108     * @param Instagram_Core_Proxy $proxy Proxy object
109     * @access public
110     */
111    public function setProxy( Instagram_Core_Proxy $proxy ) {
112        $this->proxy = $proxy;
113    }
114
115}
116?>
Note: See TracBrowser for help on using the repository browser.