]> Raphaël G. Git Repositories - airbundle/commitdiff
Add strict
authorRaphaël Gertz <git@rapsys.eu>
Mon, 23 Aug 2021 07:45:44 +0000 (09:45 +0200)
committerRaphaël Gertz <git@rapsys.eu>
Mon, 23 Aug 2021 07:45:44 +0000 (09:45 +0200)
Add preUpdate doctrine lifecycleCallbacks
Prevent sessions start and stop compute error
Add isPremium detection in session
Cleanup

Entity/Application.php
Entity/Civility.php
Entity/Group.php
Entity/Location.php
Entity/Session.php
Entity/Slot.php
Entity/Snippet.php
Entity/User.php

index af4d3a9054077551a6a48e2353e3544fa62c6ea3..b54b1e2e4cf42a20d5fbab633032d6fd4dc0b3de 100644 (file)
@@ -1,7 +1,18 @@
-<?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;
 
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
 /**
  * Application
  */
@@ -41,12 +52,20 @@ class Application {
         */
        private $user;
 
+       /**
+        * Constructor
+        */
+       public function __construct() {
+               $this->session = null;
+               $this->user = null;
+       }
+
        /**
         * Get id
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
@@ -57,7 +76,7 @@ class Application {
         *
         * @return Application
         */
-       public function setScore($score) {
+       public function setScore(?float $score): Application {
                $this->score = $score;
 
                return $this;
@@ -68,7 +87,7 @@ class Application {
         *
         * @return float
         */
-       public function getScore() {
+       public function getScore(): ?float {
                return $this->score;
        }
 
@@ -79,7 +98,7 @@ class Application {
         *
         * @return Application
         */
-       public function setCanceled($canceled) {
+       public function setCanceled(?\DateTime $canceled): Application {
                $this->canceled = $canceled;
 
                return $this;
@@ -90,7 +109,7 @@ class Application {
         *
         * @return \DateTime
         */
-       public function getCanceled() {
+       public function getCanceled(): ?\DateTime {
                return $this->canceled;
        }
 
@@ -101,7 +120,7 @@ class Application {
         *
         * @return Application
         */
-       public function setCreated($created) {
+       public function setCreated(\DateTime $created): Application {
                $this->created = $created;
 
                return $this;
@@ -112,7 +131,7 @@ class Application {
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
@@ -123,7 +142,7 @@ class Application {
         *
         * @return Application
         */
-       public function setUpdated($updated) {
+       public function setUpdated(\DateTime $updated): Application {
                $this->updated = $updated;
 
                return $this;
@@ -134,18 +153,18 @@ class Application {
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
        /**
         * Set session
         *
-        * @param \Rapsys\AirBundle\Entity\Session $session
+        * @param Session $session
         *
         * @return Application
         */
-       public function setSession(\Rapsys\AirBundle\Entity\Session $session = null) {
+       public function setSession(Session $session): Application {
                $this->session = $session;
 
                return $this;
@@ -154,20 +173,20 @@ class Application {
        /**
         * Get session
         *
-        * @return \Rapsys\AirBundle\Entity\Session
+        * @return Session
         */
-       public function getSession() {
+       public function getSession(): Session {
                return $this->session;
        }
 
        /**
         * Set user
         *
-        * @param \Rapsys\AirBundle\Entity\User $user
+        * @param User $user
         *
         * @return Application
         */
-       public function setUser(\Rapsys\AirBundle\Entity\User $user = null) {
+       public function setUser(User $user): Application {
                $this->user = $user;
 
                return $this;
@@ -176,9 +195,20 @@ class Application {
        /**
         * Get user
         *
-        * @return \Rapsys\AirBundle\Entity\User
+        * @return User
         */
-       public function getUser() {
+       public function getUser(): User {
                return $this->user;
        }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function preUpdate(PreUpdateEventArgs $eventArgs) {
+               //Check that we have an application instance
+               if (($user = $eventArgs->getEntity()) instanceof Application) {
+                       //Set updated value
+                       $user->setUpdated(new \DateTime('now'));
+               }
+       }
 }
index 86030ed2fa55bd82cd4b3fa667910e19e5e489b6..1c5466de7572728068980811283a605c1eecfdd7 100644 (file)
@@ -1,8 +1,19 @@
-<?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;
 
-class Civility extends \Rapsys\UserBundle\Entity\Civility {
+use Rapsys\UserBundle\Entity\Civility as BaseCivility;
+
+class Civility extends BaseCivility {
        /**
         * @var string
         */
@@ -15,7 +26,7 @@ class Civility extends \Rapsys\UserBundle\Entity\Civility {
         *
         * @return Civility
         */
-       public function setShort($short) {
+       public function setShort(string $short): Civility {
                $this->short = $short;
 
                return $this;
@@ -26,7 +37,7 @@ class Civility extends \Rapsys\UserBundle\Entity\Civility {
         *
         * @return string
         */
-       public function getShort() {
+       public function getShort(): string {
                return $this->short;
        }
 
index a53e1403a7d904a78966d21db91023a80015ecf5..b904a0df873e1ba2e7a96d9d9cd9aa92703d8a7e 100644 (file)
@@ -1,5 +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;
 
-class Group extends \Rapsys\UserBundle\Entity\Group {}
+use Rapsys\UserBundle\Entity\Group as BaseGroup;
+
+class Group extends BaseGroup {
+}
index fd619698cbf4ff8b455f70f728bfec446bca5737..1fdca93803149aa9a4c241536af7b21366d0d3e4 100644 (file)
@@ -1,7 +1,19 @@
-<?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;
 
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
 /**
  * Location
  */
@@ -62,17 +74,17 @@ class Location {
        private $updated;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $sessions;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $snippets;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $users;
 
@@ -80,9 +92,9 @@ class Location {
         * Constructor
         */
        public function __construct() {
-               $this->sessions = new \Doctrine\Common\Collections\ArrayCollection();
-               $this->snippets = new \Doctrine\Common\Collections\ArrayCollection();
-               $this->users = new \Doctrine\Common\Collections\ArrayCollection();
+               $this->sessions = new ArrayCollection();
+               $this->snippets = new ArrayCollection();
+               $this->users = new ArrayCollection();
        }
 
        /**
@@ -90,7 +102,7 @@ class Location {
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
@@ -101,7 +113,7 @@ class Location {
         *
         * @return Location
         */
-       public function setTitle($title) {
+       public function setTitle(string $title): Location {
                $this->title = $title;
 
                return $this;
@@ -112,7 +124,7 @@ class Location {
         *
         * @return string
         */
-       public function getTitle() {
+       public function getTitle(): string {
                return $this->title;
        }
 
@@ -123,7 +135,7 @@ class Location {
         *
         * @return Location
         */
-       public function setShort($short) {
+       public function setShort(string $short): Location {
                $this->short = $short;
 
                return $this;
@@ -134,7 +146,7 @@ class Location {
         *
         * @return string
         */
-       public function getShort() {
+       public function getShort(): string {
                return $this->short;
        }
 
@@ -145,7 +157,7 @@ class Location {
         *
         * @return Location
         */
-       public function setAddress($address) {
+       public function setAddress(string $address): Location {
                $this->address = $address;
 
                return $this;
@@ -156,7 +168,7 @@ class Location {
         *
         * @return string
         */
-       public function getAddress() {
+       public function getAddress(): string {
                return $this->address;
        }
 
@@ -167,7 +179,7 @@ class Location {
         *
         * @return Location
         */
-       public function setZipcode($zipcode) {
+       public function setZipcode(string $zipcode): Location {
                $this->zipcode = $zipcode;
 
                return $this;
@@ -178,7 +190,7 @@ class Location {
         *
         * @return string
         */
-       public function getZipcode() {
+       public function getZipcode(): string {
                return $this->zipcode;
        }
 
@@ -189,7 +201,7 @@ class Location {
         *
         * @return Location
         */
-       public function setCity($city) {
+       public function setCity(string $city): Location {
                $this->city = $city;
 
                return $this;
@@ -200,7 +212,7 @@ class Location {
         *
         * @return string
         */
-       public function getCity() {
+       public function getCity(): string {
                return $this->city;
        }
 
@@ -211,7 +223,7 @@ class Location {
         *
         * @return Location
         */
-       public function setLatitude($latitude) {
+       public function setLatitude(string $latitude): Location {
                $this->latitude = $latitude;
 
                return $this;
@@ -222,7 +234,7 @@ class Location {
         *
         * @return string
         */
-       public function getLatitude() {
+       public function getLatitude(): string {
                return $this->latitude;
        }
 
@@ -233,7 +245,7 @@ class Location {
         *
         * @return Location
         */
-       public function setLongitude($longitude) {
+       public function setLongitude(string $longitude): Location {
                $this->longitude = $longitude;
 
                return $this;
@@ -244,7 +256,7 @@ class Location {
         *
         * @return string
         */
-       public function getLongitude() {
+       public function getLongitude(): string {
                return $this->longitude;
        }
 
@@ -255,7 +267,7 @@ class Location {
         *
         * @return Session
         */
-       public function setHotspot($hotspot) {
+       public function setHotspot(bool $hotspot): Location {
                $this->hotspot = $hotspot;
 
                return $this;
@@ -266,7 +278,7 @@ class Location {
         *
         * @return boolean
         */
-       public function getHotspot() {
+       public function getHotspot(): bool {
                return $this->hotspot;
        }
 
@@ -277,7 +289,7 @@ class Location {
         *
         * @return Location
         */
-       public function setCreated($created) {
+       public function setCreated(\DateTime $created): Location {
                $this->created = $created;
 
                return $this;
@@ -288,7 +300,7 @@ class Location {
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
@@ -299,7 +311,7 @@ class Location {
         *
         * @return Location
         */
-       public function setUpdated($updated) {
+       public function setUpdated(\DateTime $updated): Location {
                $this->updated = $updated;
 
                return $this;
@@ -310,18 +322,18 @@ class Location {
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
        /**
         * Add session
         *
-        * @param \Rapsys\AirBundle\Entity\Session $session
+        * @param Session $session
         *
         * @return Location
         */
-       public function addSession(\Rapsys\AirBundle\Entity\Session $session) {
+       public function addSession(Session $session): Location {
                $this->sessions[] = $session;
 
                return $this;
@@ -330,29 +342,30 @@ class Location {
        /**
         * Remove session
         *
-        * @param \Rapsys\AirBundle\Entity\Session $session
+        * @param Session $session
+        * @return boolean
         */
-       public function removeSession(\Rapsys\AirBundle\Entity\Session $session) {
-               $this->sessions->removeElement($session);
+       public function removeSession(Session $session): bool {
+               return $this->sessions->removeElement($session);
        }
 
        /**
         * Get sessions
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getSessions() {
+       public function getSessions(): ArrayCollection {
                return $this->sessions;
        }
 
        /**
         * Add snippet
         *
-        * @param \Rapsys\AirBundle\Entity\Snippet $snippet
+        * @param Snippet $snippet
         *
         * @return Location
         */
-       public function addSnippet(\Rapsys\AirBundle\Entity\Snippet $snippet) {
+       public function addSnippet(Snippet $snippet): Location {
                $this->snippets[] = $snippet;
 
                return $this;
@@ -361,29 +374,30 @@ class Location {
        /**
         * Remove snippet
         *
-        * @param \Rapsys\AirBundle\Entity\Snippet $snippet
+        * @param Snippet $snippet
+        * @return boolean
         */
-       public function removeSnippet(\Rapsys\AirBundle\Entity\Snippet $snippet) {
-               $this->snippets->removeElement($snippet);
+       public function removeSnippet(Snippet $snippet): bool {
+               return $this->snippets->removeElement($snippet);
        }
 
        /**
         * Get snippets
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getSnippets() {
+       public function getSnippets(): ArrayCollection {
                return $this->snippets;
        }
 
        /**
         * Add user
         *
-        * @param \Rapsys\AirBundle\Entity\User $user
+        * @param User $user
         *
         * @return Location
         */
-       public function addUser(\Rapsys\AirBundle\Entity\User $user) {
+       public function addUser(User $user): Location {
                $this->users[] = $user;
 
                return $this;
@@ -392,21 +406,33 @@ class Location {
        /**
         * Remove user
         *
-        * @param \Rapsys\AirBundle\Entity\User $user
+        * @param User $user
+        * @return boolean
         */
-       public function removeUser(\Rapsys\AirBundle\Entity\User $user) {
-               $this->users->removeElement($user);
+       public function removeUser(User $user): bool {
+               return $this->users->removeElement($user);
        }
 
        /**
         * Get users
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getUsers() {
+       public function getUsers(): ArrayCollection {
                return $this->users;
        }
 
+       /**
+        * {@inheritdoc}
+        */
+       public function preUpdate(PreUpdateEventArgs $eventArgs) {
+               //Check that we have a location instance
+               if (($user = $eventArgs->getEntity()) instanceof Location) {
+                       //Set updated value
+                       $user->setUpdated(new \DateTime('now'));
+               }
+       }
+
        /**
         * Returns a string representation of the location
         *
index e7461711fdd30ff8ae3143ccb8524d5f9c1a7b5b..f5f0ef555def1e9607c9de464e99e9fbf7827961 100644 (file)
@@ -1,7 +1,19 @@
-<?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;
 
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
 /**
  * Session
  */
@@ -24,7 +36,7 @@ class Session {
        /**
         * @var \DateTime
         */
-       private $start = null;
+       private $start;
 
        /**
         * @var \DateTime
@@ -34,7 +46,7 @@ class Session {
        /**
         * @var \DateTime
         */
-       private $stop = null;
+       private $stop;
 
        /**
         * @var boolean
@@ -67,17 +79,17 @@ class Session {
        private $realfeelmax;
 
        /**
-        * @var integer
+        * @var float
         */
        private $temperature;
 
        /**
-        * @var integer
+        * @var float
         */
        private $temperaturemin;
 
        /**
-        * @var integer
+        * @var float
         */
        private $temperaturemax;
 
@@ -97,22 +109,27 @@ class Session {
        private $updated;
 
        /**
-        * @var \Rapsys\AirBundle\Entity\Application
+        * @var Application
         */
        private $application;
 
        /**
-        * @var \Rapsys\AirBundle\Entity\Location
+        * @var Dance
+        */
+       private $dance;
+
+       /**
+        * @var Location
         */
        private $location;
 
        /**
-        * @var \Rapsys\AirBundle\Entity\Slot
+        * @var Slot
         */
        private $slot;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $applications;
 
@@ -120,7 +137,21 @@ class Session {
         * Constructor
         */
        public function __construct() {
-               $this->applications = new \Doctrine\Common\Collections\ArrayCollection();
+               $this->begin = null;
+               $this->start = null;
+               $this->length = null;
+               $this->stop = null;
+               $this->rainfall = null;
+               $this->rainrisk = null;
+               $this->realfeel = null;
+               $this->realfeelmin = null;
+               $this->realfeelmax = null;
+               $this->temperature = null;
+               $this->temperaturemin = null;
+               $this->temperaturemax = null;
+               $this->locked = null;
+               $this->premium = null;
+               $this->applications = new ArrayCollection();
        }
 
        /**
@@ -128,7 +159,7 @@ class Session {
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
@@ -139,7 +170,7 @@ class Session {
         *
         * @return Session
         */
-       public function setDate($date) {
+       public function setDate(\DateTime $date): Session {
                $this->date = $date;
 
                return $this;
@@ -150,7 +181,7 @@ class Session {
         *
         * @return \DateTime
         */
-       public function getDate() {
+       public function getDate(): \DateTime {
                return $this->date;
        }
 
@@ -161,7 +192,7 @@ class Session {
         *
         * @return Session
         */
-       public function setBegin($begin) {
+       public function setBegin(?\DateTime $begin): Session {
                $this->begin = $begin;
 
                return $this;
@@ -172,7 +203,7 @@ class Session {
         *
         * @return \DateTime
         */
-       public function getBegin() {
+       public function getBegin(): ?\DateTime {
                return $this->begin;
        }
 
@@ -181,8 +212,8 @@ class Session {
         *
         * @return \DateTime
         */
-       public function getStart() {
-               //Check start
+       public function getStart(): \DateTime {
+               //With start
                if ($this->start !== null) {
                        return $this->start;
                }
@@ -197,8 +228,14 @@ class Session {
                        $this->start->add(new \DateInterval('P1D'));
                }
 
-               //Return date
-               return $this->start->setTime($this->begin->format('H'), $this->begin->format('i'), $this->begin->format('s'));
+               //With begin
+               if ($this->begin !== null) {
+                       //Set start time
+                       $this->start->setTime(intval($this->begin->format('H')), intval($this->begin->format('i')), intval($this->begin->format('s')));
+               }
+
+               //Return start
+               return $this->start;
        }
 
        /**
@@ -208,7 +245,7 @@ class Session {
         *
         * @return Session
         */
-       public function setLength($length) {
+       public function setLength(?\DateTime $length): Session {
                $this->length = $length;
 
                return $this;
@@ -219,7 +256,7 @@ class Session {
         *
         * @return \DateTime
         */
-       public function getLength() {
+       public function getLength(): ?\DateTime {
                return $this->length;
        }
 
@@ -228,7 +265,7 @@ class Session {
         *
         * @return \DateTime
         */
-       public function getStop() {
+       public function getStop(): \DateTime {
                //Check start
                if ($this->stop !== null) {
                        return $this->stop;
@@ -237,8 +274,14 @@ class Session {
                //Get start clone
                $this->stop = clone $this->getStart();
 
+               //With length
+               if ($this->length !== null) {
+                       //Set stop time
+                       $this->stop->add(new \DateInterval('PT'.$this->length->format('H').'H'.$this->length->format('i').'M'.$this->length->format('s').'S'));
+               }
+
                //Return date
-               return $this->stop->add(new \DateInterval('PT'.$this->length->format('H').'H'.$this->length->format('i').'M'.$this->length->format('s').'S'));
+               return $this->stop;
        }
 
        /**
@@ -248,7 +291,7 @@ class Session {
         *
         * @return Session
         */
-       public function setPremium($premium) {
+       public function setPremium(bool $premium): Session {
                $this->premium = $premium;
 
                return $this;
@@ -257,20 +300,20 @@ class Session {
        /**
         * Get premium
         *
-        * @return boolean
+        * @return bool
         */
-       public function getPremium() {
+       public function getPremium(): bool {
                return $this->premium;
        }
 
        /**
         * Set rainfall
         *
-        * @param boolean $rainfall
+        * @param float $rainfall
         *
         * @return Session
         */
-       public function setRainfall($rainfall) {
+       public function setRainfall(?float $rainfall): Session {
                $this->rainfall = $rainfall;
 
                return $this;
@@ -279,20 +322,20 @@ class Session {
        /**
         * Get rainfall
         *
-        * @return boolean
+        * @return float
         */
-       public function getRainfall() {
+       public function getRainfall(): ?float {
                return $this->rainfall;
        }
 
        /**
         * Set rainrisk
         *
-        * @param boolean $rainrisk
+        * @param float $rainrisk
         *
         * @return Session
         */
-       public function setRainrisk($rainrisk) {
+       public function setRainrisk(?float $rainrisk): Session {
                $this->rainrisk = $rainrisk;
 
                return $this;
@@ -301,20 +344,20 @@ class Session {
        /**
         * Get rainrisk
         *
-        * @return boolean
+        * @return float
         */
-       public function getRainrisk() {
+       public function getRainrisk(): ?float {
                return $this->rainrisk;
        }
 
        /**
         * Set realfeel
         *
-        * @param integer $realfeel
+        * @param float $realfeel
         *
         * @return Session
         */
-       public function setRealfeel($realfeel) {
+       public function setRealfeel(?float $realfeel): Session {
                $this->realfeel = $realfeel;
 
                return $this;
@@ -323,20 +366,20 @@ class Session {
        /**
         * Get realfeel
         *
-        * @return integer
+        * @return float
         */
-       public function getRealfeel() {
+       public function getRealfeel(): ?float {
                return $this->realfeel;
        }
 
        /**
         * Set realfeelmin
         *
-        * @param integer $realfeelmin
+        * @param float $realfeelmin
         *
         * @return Session
         */
-       public function setRealfeelmin($realfeelmin) {
+       public function setRealfeelmin(?float $realfeelmin): Session {
                $this->realfeelmin = $realfeelmin;
 
                return $this;
@@ -345,20 +388,20 @@ class Session {
        /**
         * Get realfeelmin
         *
-        * @return integer
+        * @return float
         */
-       public function getRealfeelmin() {
+       public function getRealfeelmin(): ?float {
                return $this->realfeelmin;
        }
 
        /**
         * Set realfeelmax
         *
-        * @param integer $realfeelmax
+        * @param float $realfeelmax
         *
         * @return Session
         */
-       public function setRealfeelmax($realfeelmax) {
+       public function setRealfeelmax(?float $realfeelmax): Session {
                $this->realfeelmax = $realfeelmax;
 
                return $this;
@@ -367,20 +410,20 @@ class Session {
        /**
         * Get realfeelmax
         *
-        * @return integer
+        * @return float
         */
-       public function getRealfeelmax() {
+       public function getRealfeelmax(): ?float {
                return $this->realfeelmax;
        }
 
        /**
         * Set temperature
         *
-        * @param integer $temperature
+        * @param float $temperature
         *
         * @return Session
         */
-       public function setTemperature($temperature) {
+       public function setTemperature(?float $temperature): Session {
                $this->temperature = $temperature;
 
                return $this;
@@ -389,20 +432,20 @@ class Session {
        /**
         * Get temperature
         *
-        * @return integer
+        * @return float
         */
-       public function getTemperature() {
+       public function getTemperature(): ?float {
                return $this->temperature;
        }
 
        /**
         * Set temperaturemin
         *
-        * @param integer $temperaturemin
+        * @param float $temperaturemin
         *
         * @return Session
         */
-       public function setTemperaturemin($temperaturemin) {
+       public function setTemperaturemin(?float $temperaturemin): Session {
                $this->temperaturemin = $temperaturemin;
 
                return $this;
@@ -411,20 +454,20 @@ class Session {
        /**
         * Get temperaturemin
         *
-        * @return integer
+        * @return float
         */
-       public function getTemperaturemin() {
+       public function getTemperaturemin(): ?float {
                return $this->temperaturemin;
        }
 
        /**
         * Set temperaturemax
         *
-        * @param integer $temperaturemax
+        * @param float $temperaturemax
         *
         * @return Session
         */
-       public function setTemperaturemax($temperaturemax) {
+       public function setTemperaturemax(?float $temperaturemax): Session {
                $this->temperaturemax = $temperaturemax;
 
                return $this;
@@ -433,9 +476,9 @@ class Session {
        /**
         * Get temperaturemax
         *
-        * @return integer
+        * @return float
         */
-       public function getTemperaturemax() {
+       public function getTemperaturemax(): ?float {
                return $this->temperaturemax;
        }
 
@@ -446,7 +489,7 @@ class Session {
         *
         * @return Session
         */
-       public function setLocked($locked) {
+       public function setLocked(?\DateTime $locked): Session {
                $this->locked = $locked;
 
                return $this;
@@ -457,7 +500,7 @@ class Session {
         *
         * @return \DateTime
         */
-       public function getLocked() {
+       public function getLocked(): ?\DateTime {
                return $this->locked;
        }
 
@@ -468,7 +511,7 @@ class Session {
         *
         * @return Session
         */
-       public function setCreated($created) {
+       public function setCreated(\DateTime $created): Session {
                $this->created = $created;
 
                return $this;
@@ -479,7 +522,7 @@ class Session {
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
@@ -490,7 +533,7 @@ class Session {
         *
         * @return Session
         */
-       public function setUpdated($updated) {
+       public function setUpdated(\DateTime $updated): Session {
                $this->updated = $updated;
 
                return $this;
@@ -501,18 +544,18 @@ class Session {
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
        /**
         * Add application
         *
-        * @param \Rapsys\AirBundle\Entity\Application $application
+        * @param Application $application
         *
         * @return Session
         */
-       public function addApplication(\Rapsys\AirBundle\Entity\Application $application) {
+       public function addApplication(Application $application): Session {
                $this->applications[] = $application;
 
                return $this;
@@ -521,29 +564,51 @@ class Session {
        /**
         * Remove application
         *
-        * @param \Rapsys\AirBundle\Entity\Application $application
+        * @param Application $application
         */
-       public function removeApplication(\Rapsys\AirBundle\Entity\Application $application) {
-               $this->applications->removeElement($application);
+       public function removeApplication(Application $application): bool {
+               return $this->applications->removeElement($application);
        }
 
        /**
         * Get applications
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getApplications() {
+       public function getApplications(): ArrayCollection {
                return $this->applications;
        }
 
+       /**
+        * Set dance
+        *
+        * @param Dance $dance
+        *
+        * @return Session
+        */
+       public function setDance(Dance $dance): Session {
+               $this->dance = $dance;
+
+               return $this;
+       }
+
+       /**
+        * Get dance
+        *
+        * @return Dance
+        */
+       public function getDance(): Dance {
+               return $this->dance;
+       }
+
        /**
         * Set location
         *
-        * @param \Rapsys\AirBundle\Entity\Location $location
+        * @param Location $location
         *
         * @return Session
         */
-       public function setLocation(\Rapsys\AirBundle\Entity\Location $location = null) {
+       public function setLocation(Location $location): Session {
                $this->location = $location;
 
                return $this;
@@ -552,20 +617,20 @@ class Session {
        /**
         * Get location
         *
-        * @return \Rapsys\AirBundle\Entity\Location
+        * @return Location
         */
-       public function getLocation() {
+       public function getLocation(): Location {
                return $this->location;
        }
 
        /**
         * Set slot
         *
-        * @param \Rapsys\AirBundle\Entity\Slot $slot
+        * @param Slot $slot
         *
         * @return Session
         */
-       public function setSlot(\Rapsys\AirBundle\Entity\Slot $slot = null) {
+       public function setSlot(Slot $slot): Session {
                $this->slot = $slot;
 
                return $this;
@@ -574,20 +639,20 @@ class Session {
        /**
         * Get slot
         *
-        * @return \Rapsys\AirBundle\Entity\Slot
+        * @return Slot
         */
-       public function getSlot() {
+       public function getSlot(): Slot {
                return $this->slot;
        }
 
        /**
         * Set application
         *
-        * @param \Rapsys\AirBundle\Entity\Application $application
+        * @param Application $application
         *
         * @return Session
         */
-       public function setApplication(\Rapsys\AirBundle\Entity\Application $application = null) {
+       public function setApplication(Application $application): Session {
                $this->application = $application;
 
                return $this;
@@ -596,9 +661,168 @@ class Session {
        /**
         * Get application
         *
-        * @return \Rapsys\AirBundle\Entity\Application
+        * @return Application
         */
-       public function getApplication() {
+       public function getApplication(): ?Application {
                return $this->application;
        }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function preUpdate(PreUpdateEventArgs $eventArgs) {
+               //Check that we have a session instance
+               if (($user = $eventArgs->getEntity()) instanceof Session) {
+                       //Set updated value
+                       $user->setUpdated(new \DateTime('now'));
+               }
+       }
+
+       /**
+        * Wether if session is a premium day
+        *
+        * Consider as premium a day off for afternoon, the eve for evening and after
+        * Store computed result in premium member for afternoon and evening
+        *
+        * @return bool Whether the date is day off or not
+        */
+       public function isPremium(): bool {
+               //Without date
+               if (empty($date = $this->date)) {
+                       throw new \LogicException('Property date is empty');
+               }
+
+               //Without slot
+               if (empty($slot = $this->slot) || empty($slotTitle = $slot->getTitle())) {
+                       throw new \LogicException('Property slot is empty');
+               }
+
+               //With evening and after slot
+               if ($slotTitle == 'Evening' || $slotTitle == 'After') {
+                       //Evening and after session is considered premium when the eve is a day off
+                       $date = (clone $date)->add(new \DateInterval('P1D'));
+               }
+
+               //Get day number
+               $w = $date->format('w');
+
+               //Check if weekend day
+               if ($w == 0 || $w == 6) {
+                       //With afternoon and evening slot
+                       if ($slotTitle == 'Afternoon' || $slotTitle == 'Evening') {
+                               //Save premium
+                               $this->premium = true;
+                       }
+
+                       //Date is weekend day
+                       return true;
+               }
+
+               //Get date day
+               $d = $date->format('d');
+
+               //Get date month
+               $m = $date->format('m');
+
+               //Check if fixed holiday
+               if (
+                       //Check if 1st january
+                       ($d == 1 && $m == 1) ||
+                       //Check if 1st may
+                       ($d == 1 && $m == 5) ||
+                       //Check if 8st may
+                       ($d == 8 && $m == 5) ||
+                       //Check if 14st july
+                       ($d == 14 && $m == 7) ||
+                       //Check if 15st august
+                       ($d == 15 && $m == 8) ||
+                       //Check if 1st november
+                       ($d == 1 && $m == 11) ||
+                       //Check if 11st november
+                       ($d == 11 && $m == 11) ||
+                       //Check if 25st december
+                       ($d == 25 && $m == 12)
+               ) {
+                       //With afternoon and evening slot
+                       if ($slotTitle == 'Afternoon' || $slotTitle == 'Evening') {
+                               //Save premium
+                               $this->premium = true;
+                       }
+
+                       //Date is a fixed holiday
+                       return true;
+               }
+
+               //Get eastern
+               $eastern = $this->getEastern($date->format('Y'));
+
+               //Check dynamic holidays
+               if (
+                       (clone $eastern)->add(new \DateInterval('P1D')) == $date ||
+                       (clone $eastern)->add(new \DateInterval('P39D')) == $date ||
+                       (clone $eastern)->add(new \DateInterval('P50D')) == $date
+               ) {
+                       //With afternoon and evening slot
+                       if ($slotTitle == 'Afternoon' || $slotTitle == 'Evening') {
+                               //Save premium
+                               $this->premium = true;
+                       }
+
+                       //Date is a dynamic holiday
+                       return true;
+               }
+
+               //With afternoon and evening slot
+               if ($slotTitle == 'Afternoon' || $slotTitle == 'Evening') {
+                       //Save premium
+                       $this->premium = false;
+               }
+
+               //Date is not a holiday and week day
+               return false;
+       }
+
+       /**
+        * Compute eastern for selected year
+        *
+        * @param string $year The eastern year
+        *
+        * @return DateTime The eastern date
+        */
+       private function getEastern(string $year): \DateTime {
+               //Set static
+               static $data = null;
+
+               //Check if already computed
+               if (isset($data[$year])) {
+                       //Return computed eastern
+                       return $data[$year];
+               //Check if data is null
+               } elseif (is_null($data)) {
+                       //Init data array
+                       $data = [];
+               }
+
+               $d = (19 * ($year % 19) + 24) % 30;
+
+               $e = (2 * ($year % 4) + 4 * ($year % 7) + 6 * $d + 5) % 7;
+
+               $day = 22 + $d + $e;
+
+               $month = 3;
+
+               if ($day > 31) {
+                       $day = $d + $e - 9;
+                       $month = 4;
+               } elseif ($d == 29 && $e == 6) {
+                       $day = 10;
+                       $month = 4;
+               } elseif ($d == 28 && $e == 6) {
+                       $day = 18;
+                       $month = 4;
+               }
+
+               //Store eastern in data
+               return ($data[$year] = new \DateTime(sprintf('%04d-%02d-%02d', $year, $month, $day)));
+       }
 }
index a46fd0bedf5c42719d84ce19995e24f5e2676df3..10e5b3d6f8bb1c48d996be97b4e72f92029328b6 100644 (file)
@@ -1,7 +1,19 @@
-<?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;
 
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
 /**
  * Slot
  */
@@ -27,7 +39,7 @@ class Slot {
        private $updated;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $sessions;
 
@@ -35,7 +47,7 @@ class Slot {
         * Constructor
         */
        public function __construct() {
-               $this->sessions = new \Doctrine\Common\Collections\ArrayCollection();
+               $this->sessions = new ArrayCollection();
        }
 
        /**
@@ -43,7 +55,7 @@ class Slot {
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
@@ -54,7 +66,7 @@ class Slot {
         *
         * @return Title
         */
-       public function setTitle($title) {
+       public function setTitle(string $title) {
                $this->title = $title;
 
                return $this;
@@ -76,7 +88,7 @@ class Slot {
         *
         * @return Slot
         */
-       public function setCreated($created) {
+       public function setCreated(\DateTime $created) {
                $this->created = $created;
 
                return $this;
@@ -87,7 +99,7 @@ class Slot {
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
@@ -98,7 +110,7 @@ class Slot {
         *
         * @return Slot
         */
-       public function setUpdated($updated) {
+       public function setUpdated(\DateTime $updated) {
                $this->updated = $updated;
 
                return $this;
@@ -109,18 +121,18 @@ class Slot {
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
        /**
         * Add session
         *
-        * @param \Rapsys\AirBundle\Entity\Session $session
+        * @param Session $session
         *
         * @return Slot
         */
-       public function addSession(\Rapsys\AirBundle\Entity\Session $session) {
+       public function addSession(Session $session): Slot {
                $this->sessions[] = $session;
 
                return $this;
@@ -129,21 +141,32 @@ class Slot {
        /**
         * Remove session
         *
-        * @param \Rapsys\AirBundle\Entity\Session $session
+        * @param Session $session
         */
-       public function removeSession(\Rapsys\AirBundle\Entity\Session $session) {
-               $this->sessions->removeElement($session);
+       public function removeSession(Session $session): bool {
+               return $this->sessions->removeElement($session);
        }
 
        /**
         * Get sessions
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getSessions() {
+       public function getSessions(): ArrayCollection {
                return $this->sessions;
        }
 
+       /**
+        * {@inheritdoc}
+        */
+       public function preUpdate(PreUpdateEventArgs $eventArgs) {
+               //Check that we have a slot instance
+               if (($user = $eventArgs->getEntity()) instanceof Slot) {
+                       //Set updated value
+                       $user->setUpdated(new \DateTime('now'));
+               }
+       }
+
        /**
         * Returns a string representation of the slot
         *
index 999091f6733d220b9f92c72cbf83cf405cdde7c2..28c7c1cdc0e6912d2b6243eddd0710da5dd6d87f 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;
 
-use Rapsys\AirBundle\Entity\Location;
-use Rapsys\AirBundle\Entity\User;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
 
 /**
  * Snippet
@@ -75,12 +83,12 @@ class Snippet {
        protected $updated;
 
        /**
-        * @var \Rapsys\UserBundle\Entity\Location
+        * @var Location
         */
        protected $location;
 
        /**
-        * @var \Rapsys\UserBundle\Entity\User
+        * @var User
         */
        protected $user;
 
@@ -88,7 +96,15 @@ class Snippet {
         * Constructor
         */
        public function __construct() {
-               $this->hat = true;
+               $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;
        }
 
        /**
@@ -96,7 +112,7 @@ class Snippet {
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
@@ -107,7 +123,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setLocale($locale) {
+       public function setLocale(string $locale): Snippet {
                $this->locale = $locale;
 
                return $this;
@@ -118,7 +134,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getLocale() {
+       public function getLocale(): string {
                return $this->locale;
        }
 
@@ -129,7 +145,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setDescription($description) {
+       public function setDescription(?string $description): Snippet {
                $this->description = $description;
 
                return $this;
@@ -140,7 +156,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getDescription() {
+       public function getDescription(): ?string {
                return $this->description;
        }
 
@@ -151,7 +167,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setClass($class) {
+       public function setClass(?string $class): Snippet {
                $this->class = $class;
 
                return $this;
@@ -162,7 +178,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getClass() {
+       public function getClass(): ?string {
                return $this->class;
        }
 
@@ -173,7 +189,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setShort($short) {
+       public function setShort(?string $short): Snippet {
                $this->short = $short;
 
                return $this;
@@ -184,7 +200,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getShort() {
+       public function getShort(): ?string {
                return $this->short;
        }
 
@@ -195,7 +211,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setRate($rate) {
+       public function setRate(?string $rate): Snippet {
                $this->rate = $rate;
 
                return $this;
@@ -206,7 +222,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getRate() {
+       public function getRate(): ?string {
                return $this->rate;
        }
 
@@ -217,7 +233,7 @@ class Snippet {
         *
         * @return User
         */
-       public function setHat(bool $hat) {
+       public function setHat(bool $hat): Snippet {
                $this->hat = $hat;
 
                return $this;
@@ -238,7 +254,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setContact($contact) {
+       public function setContact(?string $contact): Snippet {
                $this->contact = $contact;
 
                return $this;
@@ -249,7 +265,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getContact() {
+       public function getContact(): ?string {
                return $this->contact;
        }
 
@@ -260,7 +276,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setDonate($donate) {
+       public function setDonate(?string $donate): Snippet {
                $this->donate = $donate;
 
                return $this;
@@ -271,7 +287,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getDonate() {
+       public function getDonate(): ?string {
                return $this->donate;
        }
 
@@ -282,7 +298,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setLink($link) {
+       public function setLink(?string $link): Snippet {
                $this->link = $link;
 
                return $this;
@@ -293,7 +309,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getLink() {
+       public function getLink(): ?string {
                return $this->link;
        }
 
@@ -304,7 +320,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setProfile($profile) {
+       public function setProfile(?string $profile): Snippet {
                $this->profile = $profile;
 
                return $this;
@@ -315,7 +331,7 @@ class Snippet {
         *
         * @return string
         */
-       public function getProfile() {
+       public function getProfile(): ?string {
                return $this->profile;
        }
 
@@ -326,7 +342,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setCreated($created) {
+       public function setCreated(\DateTime $created): Snippet {
                $this->created = $created;
 
                return $this;
@@ -337,7 +353,7 @@ class Snippet {
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
@@ -348,7 +364,7 @@ class Snippet {
         *
         * @return Snippet
         */
-       public function setUpdated($updated) {
+       public function setUpdated(\DateTime $updated): Snippet {
                $this->updated = $updated;
 
                return $this;
@@ -359,7 +375,7 @@ class Snippet {
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
index 22bf46da496d7298ff95163b1258a6e10567bdd4..8a416011b9daf79357bfcedfeed2b0da04fa67da 100644 (file)
@@ -1,8 +1,18 @@
-<?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.
+ */
 
-// src/Rapsys/AirBundle/Entity/User.php
 namespace Rapsys\AirBundle\Entity;
 
+use Doctrine\Common\Collections\ArrayCollection;
+
 use Rapsys\AirBundle\Entity\Application;
 use Rapsys\AirBundle\Entity\Group;
 use Rapsys\AirBundle\Entity\Link;
@@ -10,33 +20,53 @@ use Rapsys\AirBundle\Entity\Snippet;
 use Rapsys\UserBundle\Entity\User as BaseUser;
 
 class User extends BaseUser {
+       /**
+        * @var string
+        */
+       protected $donate;
+
+       /**
+        * @var string
+        */
+       protected $link;
+
        /**
         * @var string
         */
        protected $phone;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var string
+        */
+       protected $profile;
+
+       /**
+        * @var ArrayCollection
         */
        private $applications;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
+        */
+       private $dances;
+
+       /**
+        * @var ArrayCollection
         */
        private $locations;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $snippets;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $subscribers;
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var ArrayCollection
         */
        private $subscriptions;
 
@@ -50,87 +80,110 @@ class User extends BaseUser {
                parent::__construct($mail);
 
                //Set collections
-               $this->applications = new \Doctrine\Common\Collections\ArrayCollection();
-               $this->locations = new \Doctrine\Common\Collections\ArrayCollection();
-               $this->snippets = new \Doctrine\Common\Collections\ArrayCollection();
-               $this->subscribers = new \Doctrine\Common\Collections\ArrayCollection();
-               $this->subscriptions = new \Doctrine\Common\Collections\ArrayCollection();
+               $this->applications = new ArrayCollection();
+               $this->dances = new ArrayCollection();
+               $this->locations = new ArrayCollection();
+               $this->snippets = new ArrayCollection();
+               $this->subscribers = new ArrayCollection();
+               $this->subscriptions = new ArrayCollection();
        }
 
        /**
-        * Set phone
+        * Set donate
         *
-        * @param string $phone
+        * @param string $donate
         *
         * @return User
         */
-       public function setPhone($phone) {
-               $this->phone = $phone;
+       public function setDonate(?string $donate): User {
+               $this->donate = $donate;
 
                return $this;
        }
 
        /**
-        * Get phone
+        * Get donate
         *
         * @return string
         */
-       public function getPhone() {
-               return $this->phone;
+       public function getDonate(): ?string {
+               return $this->donate;
+       }
+
+       /**
+        * Set link
+        *
+        * @param string $link
+        *
+        * @return User
+        */
+       public function setLink(?string $link): User {
+               $this->link = $link;
+
+               return $this;
        }
 
        /**
-        * Set donation
+        * Get link
         *
-        * @param string $donation
+        * @return string
+        */
+       public function getLink(): ?string {
+               return $this->link;
+       }
+
+       /**
+        * Set phone
+        *
+        * @param string $phone
         *
         * @return User
         */
-       public function setDonation($donation) {
-               $this->donation = $donation;
+       public function setPhone(?string $phone): User {
+               $this->phone = $phone;
 
                return $this;
        }
 
        /**
-        * Get donation
+        * Get phone
         *
         * @return string
         */
-       public function getDonation() {
-               return $this->donation;
+       public function getPhone(): ?string {
+               return $this->phone;
        }
 
        /**
-        * Set site
+        * Set profile
         *
-        * @param string $site
+        * @param string $profile
         *
         * @return User
         */
-       public function setSite($site) {
-               $this->site = $site;
+       public function setProfile(string $profile): User {
+               $this->profile = $profile;
 
                return $this;
        }
 
        /**
-        * Get site
+        * Get profile
         *
         * @return string
         */
-       public function getSite() {
-               return $this->site;
+       public function getProfile(): ?string {
+               return $this->profile;
        }
 
        /**
         * Add application
         *
-        * @param \Rapsys\AirBundle\Entity\Application $application
+        * @param Application $application
         *
         * @return User
         */
-       public function addApplication(Application $application) {
+       public function addApplication(Application $application): User {
                $this->applications[] = $application;
 
                return $this;
@@ -139,29 +192,29 @@ class User extends BaseUser {
        /**
         * Remove application
         *
-        * @param \Rapsys\AirBundle\Entity\Application $application
+        * @param Application $application
         */
-       public function removeApplication(Application $application) {
-               $this->applications->removeElement($application);
+       public function removeApplication(Application $application): bool {
+               return $this->applications->removeElement($application);
        }
 
        /**
         * Get applications
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getApplications() {
+       public function getApplications(): ArrayCollection {
                return $this->applications;
        }
 
        /**
         * Add snippet
         *
-        * @param \Rapsys\AirBundle\Entity\Snippet $snippet
+        * @param Snippet $snippet
         *
         * @return User
         */
-       public function addSnippet(Snippet $snippet) {
+       public function addSnippet(Snippet $snippet): User {
                $this->snippets[] = $snippet;
 
                return $this;
@@ -170,29 +223,62 @@ class User extends BaseUser {
        /**
         * Remove snippet
         *
-        * @param \Rapsys\AirBundle\Entity\Snippet $snippet
+        * @param Snippet $snippet
         */
-       public function removeSnippet(Snippet $snippet) {
-               $this->snippets->removeElement($snippet);
+       public function removeSnippet(Snippet $snippet): bool {
+               return $this->snippets->removeElement($snippet);
        }
 
        /**
         * Get snippets
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getSnippets() {
+       public function getSnippets(): ArrayCollection {
                return $this->snippets;
        }
 
+       /**
+        * Add dance
+        *
+        * @param Dance $dance
+        *
+        * @return User
+        */
+       public function addDance(Dance $dance): User {
+               $this->dances[] = $dance;
+
+               return $this;
+       }
+
+       /**
+        * Remove dance
+        *
+        * @param Dance $dance
+        *
+        * @return bool
+        */
+       public function removeDance(Dance $dance): bool {
+               return $this->dances->removeElement($dance);
+       }
+
+       /**
+        * Get dances
+        *
+        * @return ArrayCollection
+        */
+       public function getDances(): ArrayCollection {
+               return $this->dances;
+       }
+
        /**
         * Add location
         *
-        * @param \Rapsys\AirBundle\Entity\Location $location
+        * @param Location $location
         *
         * @return User
         */
-       public function addLocation(Location $location) {
+       public function addLocation(Location $location): User {
                $this->locations[] = $location;
 
                return $this;
@@ -201,29 +287,29 @@ class User extends BaseUser {
        /**
         * Remove location
         *
-        * @param \Rapsys\AirBundle\Entity\Location $location
+        * @param Location $location
         */
-       public function removeLocation(Location $location) {
-               $this->locations->removeElement($location);
+       public function removeLocation(Location $location): bool {
+               return $this->locations->removeElement($location);
        }
 
        /**
         * Get locations
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getLocations() {
+       public function getLocations(): ArrayCollection {
                return $this->locations;
        }
 
        /**
         * Add subscriber
         *
-        * @param \Rapsys\AirBundle\Entity\User $subscriber
+        * @param User $subscriber
         *
         * @return User
         */
-       public function addSubscriber(User $subscriber) {
+       public function addSubscriber(User $subscriber): User {
                $this->subscribers[] = $subscriber;
 
                return $this;
@@ -232,29 +318,29 @@ class User extends BaseUser {
        /**
         * Remove subscriber
         *
-        * @param \Rapsys\AirBundle\Entity\User $subscriber
+        * @param User $subscriber
         */
-       public function removeSubscriber(User $subscriber) {
-               $this->subscribers->removeElement($subscriber);
+       public function removeSubscriber(User $subscriber): bool {
+               return $this->subscribers->removeElement($subscriber);
        }
 
        /**
         * Get subscribers
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getSubscribers() {
+       public function getSubscribers(): ArrayCollection {
                return $this->subscribers;
        }
 
        /**
         * Add subscription
         *
-        * @param \Rapsys\AirBundle\Entity\User $subscription
+        * @param User $subscription
         *
         * @return User
         */
-       public function addSubscription(User $subscription) {
+       public function addSubscription(User $subscription): User {
                $this->subscriptions[] = $subscription;
 
                return $this;
@@ -263,18 +349,18 @@ class User extends BaseUser {
        /**
         * Remove subscription
         *
-        * @param \Rapsys\AirBundle\Entity\User $subscription
+        * @param User $subscription
         */
-       public function removeSubscription(User $subscription) {
-               $this->subscriptions->removeElement($subscription);
+       public function removeSubscription(User $subscription): bool {
+               return $this->subscriptions->removeElement($subscription);
        }
 
        /**
         * Get subscriptions
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return ArrayCollection
         */
-       public function getSubscriptions() {
+       public function getSubscriptions(): ArrayCollection {
                return $this->subscriptions;
        }
 }