Ejemplo n.º 1
0
 /**
  * @param  \stdClass $obj
  * @param  array     $context
  * @return TwitterMedia
  */
 public function unserialize($obj, array $context = [])
 {
     Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
     $sizesObjects = [];
     if ($obj->sizes) {
         foreach ($obj->sizes as $sizeName => $sizeObj) {
             $sizesObjects[$sizeName] = $this->mediaSizeSerializer->unserialize($sizeObj, [TwitterMediaSizeSerializer::NAME_VAR => $sizeName]);
         }
     }
     return TwitterMedia::create($obj->id, $obj->media_url, $obj->media_url_https, $obj->url, $obj->display_url, $obj->expanded_url, $sizesObjects, $obj->type, $this->entityIndicesSerializer->unserialize($obj->indices));
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function itShouldBuildTheObject()
 {
     $media = TwitterMedia::create($this->id, $this->mediaUrl, $this->mediaUrlHttps, $this->url, $this->displayUrl, $this->expandedUrl, $this->sizes, $this->type, $this->indices);
     $this->assertEquals($this->id, $media->getId());
     $this->assertEquals($this->mediaUrl, $media->getMediaUrl());
     $this->assertEquals($this->mediaUrlHttps, $media->getMediaUrlHttps());
     $this->assertEquals($this->url, $media->getUrl());
     $this->assertEquals($this->displayUrl, $media->getDisplayUrl());
     $this->assertEquals($this->expandedUrl, $media->getExpandedUrl());
     $this->assertEquals($this->sizes, $media->getSizes());
     $this->assertEquals($this->type, $media->getType());
     $this->assertEquals($this->indices, $media->getIndices());
 }
Ejemplo n.º 3
0
 /**
  * @return TwitterMedia
  */
 private function getValidObject()
 {
     return TwitterMedia::create($this->id, $this->mediaUrl, $this->mediaUrlHttps, $this->url, $this->displayUrl, $this->expandedUrl, [$this->mediaSize], $this->type, $this->indices);
 }