vendor/tchoulom/view-counter-bundle/Entity/ViewCounter.php line 31

Open in your IDE?
  1. <?php
  2. /**
  3.  * This file is part of the TchoulomViewCounterBundle package.
  4.  *
  5.  * @package    TchoulomViewCounterBundle
  6.  * @author     Original Author <tchoulomernest@yahoo.fr>
  7.  *
  8.  * (c) Ernest TCHOULOM
  9.  *
  10.  * For the full copyright and license information, please view the LICENSE
  11.  * file that was distributed with this source code.
  12.  */
  13. namespace Tchoulom\ViewCounterBundle\Entity;
  14. use DateTimeInterface;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Doctrine\ORM\Mapping\MappedSuperclass;
  17. use Doctrine\ORM\Mapping\HasLifecycleCallbacks;
  18. use Tchoulom\ViewCounterBundle\Model\ViewCountable;
  19. /**
  20.  * ViewCounter Entity
  21.  *
  22.  * @ORM\MappedSuperclass
  23.  * @ORM\HasLifecycleCallbacks
  24.  */
  25. #[ORM\MappedSuperclass]
  26. #[ORM\HasLifecycleCallbacks]
  27. abstract class ViewCounter implements ViewCounterInterface
  28. {
  29.     /**
  30.      * @ORM\Id
  31.      * @ORM\Column(type="integer")
  32.      * @ORM\GeneratedValue(strategy="AUTO")
  33.      */
  34.     #[ORM\Id]
  35.     #[ORM\Column(type'integer')]
  36.     #[ORM\GeneratedValue(strategy'AUTO')]
  37.     protected $id;
  38.     /**
  39.      * @var text $ip
  40.      *
  41.      * @ORM\Column(name="ip", type="text", nullable=false)
  42.      */
  43.     #[ORM\Column(name'ip'type'text'nullablefalse)]
  44.     protected $ip;
  45.     /**
  46.      * @var DateTimeInterface
  47.      *
  48.      * @ORM\Column(name="view_date", type="datetime", nullable=false)
  49.      */
  50.     #[ORM\Column(name'view_date'type'datetime'nullablefalse)]
  51.     protected $viewDate;
  52.     /**
  53.      * The property name.
  54.      *
  55.      * @var string
  56.      */
  57.     protected $property;
  58.     /**
  59.      * Gets the ID
  60.      *
  61.      * @return integer
  62.      */
  63.     public function getId()
  64.     {
  65.         return $this->id;
  66.     }
  67.     /**
  68.      * Gets the IP
  69.      *
  70.      * @return text
  71.      */
  72.     public function getIp()
  73.     {
  74.         return $this->ip;
  75.     }
  76.     /**
  77.      * Sets viewDate
  78.      *
  79.      * @param $ip
  80.      *
  81.      * @return self
  82.      */
  83.     public function setIp($ip)
  84.     {
  85.         $this->ip $ip;
  86.         return $this;
  87.     }
  88.     /**
  89.      * Gets viewDate
  90.      *
  91.      * @return DateTimeInterface
  92.      */
  93.     public function getViewDate()
  94.     {
  95.         return $this->viewDate;
  96.     }
  97.     /**
  98.      * Sets viewDate
  99.      *
  100.      * @param DateTimeInterface $viewDate
  101.      *
  102.      * @return self
  103.      */
  104.     public function setViewDate(DateTimeInterface $viewDate)
  105.     {
  106.         $this->viewDate $viewDate;
  107.         return $this;
  108.     }
  109.     /**
  110.      * Sets the property name.
  111.      *
  112.      * @param string $property
  113.      *
  114.      * @return self
  115.      */
  116.     public function setProperty(string $property): self
  117.     {
  118.         $this->property $property;
  119.         return $this;
  120.     }
  121.     /**
  122.      * Gets the property name.
  123.      *
  124.      * @return string
  125.      */
  126.     public function getProperty(): string
  127.     {
  128.         return $this->property;
  129.     }
  130.     /**
  131.      * Sets the page.
  132.      *
  133.      * @param ViewCountable $page
  134.      * @param string $property
  135.      *
  136.      * @return self
  137.      */
  138.     public function setPage(ViewCountable $page): self
  139.     {
  140.         $property $this->getProperty();
  141.         $setPage 'set' ucfirst($property);
  142.         $this->$setPage($page);
  143.         return $this;
  144.     }
  145.     /**
  146.      * Gets the page.
  147.      *
  148.      * @return ViewCountable|null
  149.      */
  150.     public function getPage(): ?ViewCountable
  151.     {
  152.         $property $this->getProperty();
  153.         $getPage 'get' ucfirst($property);
  154.         $page $this->$getPage();
  155.         return $page;
  156.     }
  157. }