src/AppBundle/Prismic/Movie.php line 91

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Prismic;
  3. use DateTime;
  4. use Prismic\Dom\RichText;
  5. use stdClass;
  6. class Movie
  7. {
  8.     /**
  9.      * @var string
  10.      */
  11.     public $uid;
  12.     /**
  13.      * @var string
  14.      */
  15.     public $published_at;
  16.     /**
  17.      * @var string
  18.      */
  19.     public $title;
  20.     /**
  21.      * @var string
  22.      */
  23.     public $subtitle;
  24.     /**
  25.      * @var string
  26.      */
  27.     public $imageUrl;
  28.     /**
  29.      * @var string
  30.      */
  31.     public $imageAlt;
  32.     /**
  33.      * @var string
  34.      */
  35.     public $originalTitle;
  36.     /**
  37.      * @var int
  38.      */
  39.     public $runtime;
  40.     /**
  41.      * @var string
  42.      */
  43.     public $year;
  44.     /**
  45.      * @var string
  46.      */
  47.     public $director;
  48.     /**
  49.      * @var string
  50.      */
  51.     public $writers;
  52.     /**
  53.      * @var string
  54.      */
  55.     public $cast;
  56.     /**
  57.      * @var string
  58.      */
  59.     public $country;
  60.     /**
  61.      * @var \DateTime
  62.      */
  63.     public $releaseDate;
  64.     /**
  65.      * @var string
  66.      */
  67.     public $youtube;
  68.     /**
  69.      * @param stdClass $document
  70.      */
  71.     public function __construct(stdClass $document)
  72.     {
  73.         $this->uid $document->uid;
  74.         $this->published_at = (new DateTime($document->published_at))->format('d/m/Y');
  75.         $this->title $document->title ?? null;
  76.         $this->subtitle $document->subtitle ?? null;
  77.         $this->imageUrl $document->image->url ?? null;
  78.         $this->imageAlt $document->image->alt ?? null;
  79.         $this->originalTitle $document->original_title ?? null;
  80.         $this->runtime $document->runtime ?? null;
  81.         $this->year $document->year ?? null;
  82.         $this->director $document->director ?? null;
  83.         $this->writers $document->writers ?? null;
  84.         $this->cast $document->cast ?? null;
  85.         $this->country $document->country ?? null;
  86.         $this->releaseDate $document->release_date ?? null;
  87.         $this->youtube $document->youtube ?? null;
  88.     }
  89.     /**
  90.      * @param stdClass $document
  91.      *
  92.      * @return self
  93.      */
  94.     public static function create(stdClass $document): self
  95.     {
  96.         return new static($document);
  97.     }
  98. }