Version 1
[yaffs-website] / vendor / php-instagram-api / php-instagram-api / Instagram / Comment.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\User;
12
13 /**
14  * Comment class
15  *
16  * @see \Instagram\CurrentUser::addMediaComment()
17  * @see \Instagram\CurrentUser::deleteMediaComment()
18  * @see \Instagram\Media::getCaption()
19  * @see \Instagram\Media::getComments()
20  */
21 class Comment extends \Instagram\Core\BaseObjectAbstract {
22
23     /**
24      * Cached user
25      * 
26      * @var \Instagram\User
27      */
28     protected $user = null;
29
30     /**
31      * Get comment creation time
32      *
33      * @param $format Time format {@link http://php.net/manual/en/function.date.php}
34      * @return string Returns the creation time with optional formatting
35      * @access public
36      */
37     public function getCreatedTime( $format = null ) {
38         if ( $format ) {
39             $date = date( $format, $this->data->created_time );
40         }
41         else {
42             $date = $this->data->created_time;
43         }
44         return $date;
45     }
46
47     /**
48      * Get the comment text
49      *
50      * @access public
51      * @return string
52      */
53     public function getText() {
54         return $this->data->text;
55     }
56
57     /**
58      * Get the comment's user
59      *
60      * @access public
61      * @return \Instagram\User
62      */
63     public function getUser() {
64         if ( !$this->user ) {
65             $this->user = new User( $this->data->from, $this->proxy );
66         }
67         return $this->user;
68     }
69
70     /**
71      * Magic toString method
72      *
73      * Return the comment text
74      *
75      * @access public
76      * @return string
77      */
78     public function __toString() {
79         return $this->getText();
80     }
81
82 }