]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Snippet.php
Fix header comment
[airbundle] / Entity / Snippet.php
index 999091f6733d220b9f92c72cbf83cf405cdde7c2..fa5fe996fbcc68d74fc4ccf6d7dec693aaeef29a 100644 (file)
@@ -1,9 +1,17 @@
-<?php
+<?php declare(strict_types=1);
+
+/*
+ * this file is part of the rapsys packbundle 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
 
 /**
  * Snippet
@@ -75,12 +83,12 @@ class Snippet {
        protected $updated;
 
        /**
        protected $updated;
 
        /**
-        * @var \Rapsys\UserBundle\Entity\Location
+        * @var Location
         */
        protected $location;
 
        /**
         */
        protected $location;
 
        /**
-        * @var \Rapsys\UserBundle\Entity\User
+        * @var User
         */
        protected $user;
 
         */
        protected $user;
 
@@ -88,7 +96,19 @@ class Snippet {
         * Constructor
         */
        public function __construct() {
         * Constructor
         */
        public function __construct() {
-               $this->hat = true;
+               //Set defaults
+               $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;
+               $this->location = null;
+               $this->created = new \DateTime('now');
+               $this->updated = new \DateTime('now');
        }
 
        /**
        }
 
        /**
@@ -96,7 +116,7 @@ class Snippet {
         *
         * @return integer
         */
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
                return $this->id;
        }
 
@@ -107,7 +127,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;
@@ -118,7 +138,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getLocale() {
+       public function getLocale(): string {
                return $this->locale;
        }
 
                return $this->locale;
        }
 
@@ -129,7 +149,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;
@@ -140,7 +160,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getDescription() {
+       public function getDescription(): ?string {
                return $this->description;
        }
 
                return $this->description;
        }
 
@@ -151,7 +171,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;
@@ -162,7 +182,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getClass() {
+       public function getClass(): ?string {
                return $this->class;
        }
 
                return $this->class;
        }
 
@@ -173,7 +193,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;
@@ -184,18 +204,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;
@@ -204,9 +224,9 @@ class Snippet {
        /**
         * Get rate
         *
        /**
         * Get rate
         *
-        * @return string
+        * @return int
         */
         */
-       public function getRate() {
+       public function getRate(): ?int {
                return $this->rate;
        }
 
                return $this->rate;
        }
 
@@ -217,7 +237,7 @@ class Snippet {
         *
         * @return User
         */
         *
         * @return User
         */
-       public function setHat(bool $hat) {
+       public function setHat(?bool $hat): Snippet {
                $this->hat = $hat;
 
                return $this;
                $this->hat = $hat;
 
                return $this;
@@ -228,7 +248,7 @@ class Snippet {
         *
         * @return bool
         */
         *
         * @return bool
         */
-       public function getHat(): bool {
+       public function getHat(): ?bool {
                return $this->hat;
        }
        /**
                return $this->hat;
        }
        /**
@@ -238,7 +258,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;
@@ -249,7 +269,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getContact() {
+       public function getContact(): ?string {
                return $this->contact;
        }
 
                return $this->contact;
        }
 
@@ -260,7 +280,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;
@@ -271,7 +291,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getDonate() {
+       public function getDonate(): ?string {
                return $this->donate;
        }
 
                return $this->donate;
        }
 
@@ -282,7 +302,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;
@@ -293,7 +313,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getLink() {
+       public function getLink(): ?string {
                return $this->link;
        }
 
                return $this->link;
        }
 
@@ -304,7 +324,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;
@@ -315,7 +335,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getProfile() {
+       public function getProfile(): ?string {
                return $this->profile;
        }
 
                return $this->profile;
        }
 
@@ -326,7 +346,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;
@@ -337,7 +357,7 @@ class Snippet {
         *
         * @return \DateTime
         */
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
                return $this->created;
        }
 
@@ -348,7 +368,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;
@@ -359,7 +379,7 @@ class Snippet {
         *
         * @return \DateTime
         */
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
                return $this->updated;
        }
 
@@ -410,9 +430,9 @@ class Snippet {
        /**
         * {@inheritdoc}
         */
        /**
         * {@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'));
                }