]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Snippet.php
Remove googleScopes const
[airbundle] / Entity / Snippet.php
index 99bc040a170e26b1b28dd45dbc16ab1175da9dae..dea8897dd0fe3e0b68416b46378d0edec0fb0c38 100644 (file)
-<?php
+<?php declare(strict_types=1);
+
+/*
+ * This file is part of the Rapsys AirBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
 
 namespace Rapsys\AirBundle\Entity;
 
 
 namespace Rapsys\AirBundle\Entity;
 
-use Rapsys\AirBundle\Entity\Location;
-use Rapsys\AirBundle\Entity\User;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
 
 /**
  * Snippet
  */
 class Snippet {
        /**
 
 /**
  * Snippet
  */
 class Snippet {
        /**
-        * @var integer
-        */
-       private $id;
-
-       /**
-        * @var string
+        * Primary key
         */
         */
-       protected $locale;
+       private ?int $id = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $description;
+       private ?string $description = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $class;
+       private ?string $class = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $short;
+       private ?string $short = null;
 
        /**
         * @var integer
         */
 
        /**
         * @var integer
         */
-       protected $rate;
+       private ?int $rate = null;
 
        /**
 
        /**
-        * @var string
+        * @var bool
         */
         */
-       protected $contact;
+       private ?bool $hat = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $donate;
+       private ?string $contact = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $link;
+       private ?string $donate = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $profile;
+       private ?string $link = null;
 
        /**
 
        /**
-        * @var \DateTime
+        * @var string
         */
         */
-       protected $created;
+       private ?string $profile = null;
 
        /**
 
        /**
-        * @var \DateTime
+        * Create datetime
         */
         */
-       protected $updated;
+       private \DateTime $created;
 
        /**
 
        /**
-        * @var \Rapsys\UserBundle\Entity\Location
+        * Update datetime
         */
         */
-       protected $location;
+       private \DateTime $updated;
 
        /**
 
        /**
-        * @var \Rapsys\UserBundle\Entity\User
+        * Constructor
+        *
+        * @param string $locale The locale
+        * @param Location $location The location instance
+        * @param User $user The user instance
         */
         */
-       protected $user;
+       public function __construct(private string $locale, private Location $location, private User $user) {
+               //Set defaults
+               $this->created = new \DateTime('now');
+               $this->updated = new \DateTime('now');
+       }
 
        /**
         * Get id
         *
         * @return integer
         */
 
        /**
         * Get id
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): ?int {
                return $this->id;
        }
 
                return $this->id;
        }
 
@@ -95,7 +106,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setLocale($locale) {
+       public function setLocale(string $locale): Snippet {
                $this->locale = $locale;
 
                return $this;
                $this->locale = $locale;
 
                return $this;
@@ -106,7 +117,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getLocale() {
+       public function getLocale(): string {
                return $this->locale;
        }
 
                return $this->locale;
        }
 
@@ -117,7 +128,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setDescription($description) {
+       public function setDescription(?string $description): Snippet {
                $this->description = $description;
 
                return $this;
                $this->description = $description;
 
                return $this;
@@ -128,7 +139,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getDescription() {
+       public function getDescription(): ?string {
                return $this->description;
        }
 
                return $this->description;
        }
 
@@ -139,7 +150,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setClass($class) {
+       public function setClass(?string $class): Snippet {
                $this->class = $class;
 
                return $this;
                $this->class = $class;
 
                return $this;
@@ -150,7 +161,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getClass() {
+       public function getClass(): ?string {
                return $this->class;
        }
 
                return $this->class;
        }
 
@@ -161,7 +172,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setShort($short) {
+       public function setShort(?string $short): Snippet {
                $this->short = $short;
 
                return $this;
                $this->short = $short;
 
                return $this;
@@ -172,18 +183,18 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getShort() {
+       public function getShort(): ?string {
                return $this->short;
        }
 
        /**
         * Set rate
         *
                return $this->short;
        }
 
        /**
         * Set rate
         *
-        * @param string $rate
+        * @param int $rate
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setRate($rate) {
+       public function setRate(?int $rate): Snippet {
                $this->rate = $rate;
 
                return $this;
                $this->rate = $rate;
 
                return $this;
@@ -192,12 +203,33 @@ class Snippet {
        /**
         * Get rate
         *
        /**
         * Get rate
         *
-        * @return string
+        * @return int
         */
         */
-       public function getRate() {
+       public function getRate(): ?int {
                return $this->rate;
        }
 
                return $this->rate;
        }
 
+       /**
+        * Set hat
+        *
+        * @param bool $hat
+        *
+        * @return User
+        */
+       public function setHat(?bool $hat): Snippet {
+               $this->hat = $hat;
+
+               return $this;
+       }
+
+       /**
+        * Get hat
+        *
+        * @return bool
+        */
+       public function getHat(): ?bool {
+               return $this->hat;
+       }
        /**
         * Set contact
         *
        /**
         * Set contact
         *
@@ -205,7 +237,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setContact($contact) {
+       public function setContact(?string $contact): Snippet {
                $this->contact = $contact;
 
                return $this;
                $this->contact = $contact;
 
                return $this;
@@ -216,7 +248,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getContact() {
+       public function getContact(): ?string {
                return $this->contact;
        }
 
                return $this->contact;
        }
 
@@ -227,7 +259,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setDonate($donate) {
+       public function setDonate(?string $donate): Snippet {
                $this->donate = $donate;
 
                return $this;
                $this->donate = $donate;
 
                return $this;
@@ -238,7 +270,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getDonate() {
+       public function getDonate(): ?string {
                return $this->donate;
        }
 
                return $this->donate;
        }
 
@@ -249,7 +281,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setLink($link) {
+       public function setLink(?string $link): Snippet {
                $this->link = $link;
 
                return $this;
                $this->link = $link;
 
                return $this;
@@ -260,7 +292,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getLink() {
+       public function getLink(): ?string {
                return $this->link;
        }
 
                return $this->link;
        }
 
@@ -271,7 +303,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setProfile($profile) {
+       public function setProfile(?string $profile): Snippet {
                $this->profile = $profile;
 
                return $this;
                $this->profile = $profile;
 
                return $this;
@@ -282,7 +314,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getProfile() {
+       public function getProfile(): ?string {
                return $this->profile;
        }
 
                return $this->profile;
        }
 
@@ -293,7 +325,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setCreated($created) {
+       public function setCreated(\DateTime $created): Snippet {
                $this->created = $created;
 
                return $this;
                $this->created = $created;
 
                return $this;
@@ -304,7 +336,7 @@ class Snippet {
         *
         * @return \DateTime
         */
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
                return $this->created;
        }
 
@@ -315,7 +347,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setUpdated($updated) {
+       public function setUpdated(\DateTime $updated): Snippet {
                $this->updated = $updated;
 
                return $this;
                $this->updated = $updated;
 
                return $this;
@@ -326,7 +358,7 @@ class Snippet {
         *
         * @return \DateTime
         */
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
                return $this->updated;
        }
 
@@ -337,7 +369,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setLocation(Location $location) {
+       public function setLocation(Location $location): Snippet {
                $this->location = $location;
 
                return $this;
                $this->location = $location;
 
                return $this;
@@ -348,7 +380,7 @@ class Snippet {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function getLocation() {
+       public function getLocation(): Location {
                return $this->location;
        }
 
                return $this->location;
        }
 
@@ -359,7 +391,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setUser(User $user) {
+       public function setUser(User $user): Snippet {
                $this->user = $user;
 
                return $this;
                $this->user = $user;
 
                return $this;
@@ -370,16 +402,16 @@ class Snippet {
         *
         * @return User
         */
         *
         * @return User
         */
-       public function getUser() {
+       public function getUser(): User {
                return $this->user;
        }
 
        /**
         * {@inheritdoc}
         */
                return $this->user;
        }
 
        /**
         * {@inheritdoc}
         */
-       public function preUpdate(\Doctrine\ORM\Event\PreUpdateEventArgs  $eventArgs) {
+       public function preUpdate(PreUpdateEventArgs $eventArgs) {
                //Check that we have an snippet instance
                //Check that we have an snippet instance
-               if (($snippet = $eventArgs->getEntity()) instanceof Snippet) {
+               if (($snippet = $eventArgs->getObject()) instanceof Snippet) {
                        //Set updated value
                        $snippet->setUpdated(new \DateTime('now'));
                }
                        //Set updated value
                        $snippet->setUpdated(new \DateTime('now'));
                }