source: extensions/instagram2piwigo/include/Instagram/Comment.php @ 19561

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

first commit

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