vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/Domain/Model/PreviewLink.php line 14

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Sulu.
  4.  *
  5.  * (c) Sulu GmbH
  6.  *
  7.  * This source file is subject to the MIT license that is bundled
  8.  * with this source code in the file LICENSE.
  9.  */
  10. namespace Sulu\Bundle\PreviewBundle\Domain\Model;
  11. class PreviewLink implements PreviewLinkInterface
  12. {
  13.     /**
  14.      * @var int
  15.      */
  16.     private $id;
  17.     /**
  18.      * @var string
  19.      */
  20.     private $token;
  21.     /**
  22.      * @var string
  23.      */
  24.     private $resourceKey;
  25.     /**
  26.      * @var string
  27.      */
  28.     private $resourceId;
  29.     /**
  30.      * @var string
  31.      */
  32.     private $locale;
  33.     /**
  34.      * @var array<string, mixed>
  35.      */
  36.     private $options;
  37.     /**
  38.      * @var int
  39.      */
  40.     private $visitCount 0;
  41.     /**
  42.      * @var \DateTimeImmutable|null
  43.      */
  44.     private $lastVisit;
  45.     public function __construct(string $tokenstring $resourceKeystring $resourceIdstring $locale, array $options)
  46.     {
  47.         $this->token $token;
  48.         $this->resourceKey $resourceKey;
  49.         $this->resourceId $resourceId;
  50.         $this->locale $locale;
  51.         $this->options $options;
  52.     }
  53.     public function getId(): int
  54.     {
  55.         return $this->id;
  56.     }
  57.     public function getToken(): string
  58.     {
  59.         return $this->token;
  60.     }
  61.     public function getResourceKey(): string
  62.     {
  63.         return $this->resourceKey;
  64.     }
  65.     public function getResourceId(): string
  66.     {
  67.         return $this->resourceId;
  68.     }
  69.     public function getLocale(): string
  70.     {
  71.         return $this->locale;
  72.     }
  73.     public function getOptions(): array
  74.     {
  75.         return $this->options;
  76.     }
  77.     public function getVisitCount(): int
  78.     {
  79.         return $this->visitCount;
  80.     }
  81.     public function increaseVisitCount(): PreviewLinkInterface
  82.     {
  83.         ++$this->visitCount;
  84.         $this->lastVisit = new \DateTimeImmutable();
  85.         return $this;
  86.     }
  87.     public function getLastVisit(): ?\DateTimeImmutable
  88.     {
  89.         return $this->lastVisit;
  90.     }
  91.     /**
  92.      * @param mixed[] $options
  93.      */
  94.     public static function create(string $tokenstring $resourceKeystring $resourceIdstring $locale, array $options): PreviewLinkInterface
  95.     {
  96.         return new self(
  97.             $token,
  98.             $resourceKey,
  99.             $resourceId,
  100.             $locale,
  101.             $options
  102.         );
  103.     }
  104. }