]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Snippet.php
Remove googleScopes const
[airbundle] / Entity / Snippet.php
index 28c7c1cdc0e6912d2b6243eddd0710da5dd6d87f..dea8897dd0fe3e0b68416b46378d0edec0fb0c38 100644 (file)
@@ -1,11 +1,11 @@
 <?php declare(strict_types=1);
 
 /*
 <?php declare(strict_types=1);
 
 /*
- * this file is part of the rapsys packbundle package.
+ * This file is part of the Rapsys AirBundle package.
  *
  *
- * (c) raphaël gertz <symfony@rapsys.eu>
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
  *
  *
- * for the full copyright and license information, please view the license
+ * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
 
  * file that was distributed with this source code.
  */
 
@@ -18,93 +18,76 @@ use Doctrine\ORM\Event\PreUpdateEventArgs;
  */
 class Snippet {
        /**
  */
 class Snippet {
        /**
-        * @var integer
+        * Primary key
         */
         */
-       private $id;
+       private ?int $id = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $locale;
+       private ?string $description = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $description;
+       private ?string $class = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $class;
-
-       /**
-        * @var string
-        */
-       protected $short;
+       private ?string $short = null;
 
        /**
         * @var integer
         */
 
        /**
         * @var integer
         */
-       protected $rate;
+       private ?int $rate = null;
 
        /**
         * @var bool
         */
 
        /**
         * @var bool
         */
-       protected $hat;
+       private ?bool $hat = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $contact;
+       private ?string $contact = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $donate;
+       private ?string $donate = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $link;
+       private ?string $link = null;
 
        /**
         * @var string
         */
 
        /**
         * @var string
         */
-       protected $profile;
+       private ?string $profile = null;
 
        /**
 
        /**
-        * @var \DateTime
+        * Create datetime
         */
         */
-       protected $created;
+       private \DateTime $created;
 
        /**
 
        /**
-        * @var \DateTime
+        * Update datetime
         */
         */
-       protected $updated;
-
-       /**
-        * @var Location
-        */
-       protected $location;
-
-       /**
-        * @var User
-        */
-       protected $user;
+       private \DateTime $updated;
 
        /**
         * Constructor
 
        /**
         * Constructor
+        *
+        * @param string $locale The locale
+        * @param Location $location The location instance
+        * @param User $user The user instance
         */
         */
-       public function __construct() {
-               $this->description = null;
-               $this->class = null;
-               $this->short = null;
-               $this->rate = null;
-               $this->hat = null;
-               $this->contact = null;
-               $this->donate = null;
-               $this->link = null;
-               $this->profile = null;
+       public function __construct(private string $locale, private Location $location, private User $user) {
+               //Set defaults
+               $this->created = new \DateTime('now');
+               $this->updated = new \DateTime('now');
        }
 
        /**
        }
 
        /**
@@ -112,7 +95,7 @@ class Snippet {
         *
         * @return integer
         */
         *
         * @return integer
         */
-       public function getId(): int {
+       public function getId(): ?int {
                return $this->id;
        }
 
                return $this->id;
        }
 
@@ -207,11 +190,11 @@ class Snippet {
        /**
         * Set rate
         *
        /**
         * Set rate
         *
-        * @param string $rate
+        * @param int $rate
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setRate(?string $rate): Snippet {
+       public function setRate(?int $rate): Snippet {
                $this->rate = $rate;
 
                return $this;
                $this->rate = $rate;
 
                return $this;
@@ -220,9 +203,9 @@ class Snippet {
        /**
         * Get rate
         *
        /**
         * Get rate
         *
-        * @return string
+        * @return int
         */
         */
-       public function getRate(): ?string {
+       public function getRate(): ?int {
                return $this->rate;
        }
 
                return $this->rate;
        }
 
@@ -233,7 +216,7 @@ class Snippet {
         *
         * @return User
         */
         *
         * @return User
         */
-       public function setHat(bool $hat): Snippet {
+       public function setHat(?bool $hat): Snippet {
                $this->hat = $hat;
 
                return $this;
                $this->hat = $hat;
 
                return $this;
@@ -244,7 +227,7 @@ class Snippet {
         *
         * @return bool
         */
         *
         * @return bool
         */
-       public function getHat(): bool {
+       public function getHat(): ?bool {
                return $this->hat;
        }
        /**
                return $this->hat;
        }
        /**
@@ -386,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;
@@ -397,7 +380,7 @@ class Snippet {
         *
         * @return Location
         */
         *
         * @return Location
         */
-       public function getLocation() {
+       public function getLocation(): Location {
                return $this->location;
        }
 
                return $this->location;
        }
 
@@ -408,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;
@@ -419,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'));
                }