Ejemplo n.º 1
0
 /**
  * @param  \stdClass $obj
  * @param  array     $context
  * @return TwitterEvent
  */
 public function unserialize($obj, array $context = [])
 {
     Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
     $createdAt = new \DateTimeImmutable($obj->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return TwitterEvent::create($obj->event, $this->userSerializer->unserialize($obj->source), isset($obj->target) ? $this->userSerializer->unserialize($obj->target) : null, isset($obj->target_object) ? $this->targetSerializer->unserialize($obj->target_object) : null, $createdAt);
 }
Ejemplo n.º 2
0
 /**
  * @param  \stdClass $obj
  * @param  array     $context
  * @return \Twitter\Object\Tweet
  */
 public function unserialize($obj, array $context = [])
 {
     Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
     $createdAt = new \DateTimeImmutable($obj->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return Tweet::create(TwitterMessageId::create($obj->id), $this->userSerializer->unserialize($obj->user), $obj->text, $obj->lang, $createdAt, $obj->entities ? $this->twitterEntitiesSerializer->unserialize($obj->entities) : TwitterEntities::create(), $obj->coordinates ? $this->coordinatesSerializer->unserialize($obj->coordinates) : null, $obj->place ? $this->placeSerializer->unserialize($obj->place) : null, $obj->in_reply_to_status_id, $obj->in_reply_to_user_id, $obj->in_reply_to_screen_name, $obj->retweeted, $obj->retweet_count, $obj->favorited, $obj->favorite_count, $obj->truncated, $obj->source, isset($obj->retweeted_status) ? $this->unserialize($obj->retweeted_status) : null);
 }
 /**
  * @param  \stdClass $directMessage
  * @param  array     $context
  * @return TwitterDirectMessage
  */
 public function unserialize($directMessage, array $context = [])
 {
     Assertion::true($this->canUnserialize($directMessage), 'object is not unserializable');
     $dm = $directMessage->direct_message;
     $createdAt = new \DateTimeImmutable($dm->created_at);
     Assertion::eq(new \DateTimeZone('UTC'), $createdAt->getTimezone());
     return TwitterDirectMessage::create(TwitterMessageId::create($dm->id), $this->userSerializer->unserialize($dm->sender), $this->userSerializer->unserialize($dm->recipient), $dm->text, $createdAt, $this->twitterEntitiesSerializer->canUnserialize($dm->entities) ? $this->twitterEntitiesSerializer->unserialize($dm->entities) : TwitterEntities::create());
 }
Ejemplo n.º 4
0
 /**
  * @param boolean $ago Do we add 'ago' to interval.
  *
  * @return string
  * @since 2015-08-07
  */
 public function ago($ago = true)
 {
     $l = $this->lang;
     $s = $l->seperator();
     $to = $this->to;
     if ($to === null) {
         $to = new \DateTimeImmutable('now', $this->from->getTimezone());
     }
     $int = $this->from->diff($to);
     $ret = $l->format($int, $ago);
     return $ret;
 }
Ejemplo n.º 5
0
 public function setExpires($expires)
 {
     if ($expires === NULL) {
         $this->expires = NULL;
     } else {
         if (is_numeric($expires)) {
             $expires = new \DateTimeImmutable('@' . $expires);
         } elseif ($expires instanceof \DateTimeInterface) {
             $expires = new \DateTimeImmutable('@' . $expires->getTimestamp(), $expires->getTimezone());
         } else {
             $expires = \DateTimeImmutable::createFromFormat(Http::DATE_COOKIE, $expires);
         }
         $this->expires = $expires->setTimezone(new \DateTimeZone('UTC'));
     }
 }
Ejemplo n.º 6
0
 /**
  * @return bool TRUE if the token has expired (and is invalid); FALSE otherwise.
  */
 public function hasExpired() : bool
 {
     return $this->expires <= new \DateTimeImmutable('now', $this->expires->getTimezone());
 }
Ejemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function getTimezone()
 {
     return $this->prototype->getTimezone();
 }