-<?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\UserBundle\Entity;
+use Doctrine\Common\Collections\ArrayCollection;
+
+use Rapsys\UserBundle\Entity\User;
+
/**
* Civility
*/
protected $updated;
/**
- * @var \Doctrine\Common\Collections\Collection
+ * @var ArrayCollection
*/
protected $users;
* Constructor
*/
public function __construct() {
- $this->users = new \Doctrine\Common\Collections\ArrayCollection();
+ $this->users = new ArrayCollection();
}
/**
*
* @return integer
*/
- public function getId() {
+ public function getId(): int {
return $this->id;
}
*
* @return Civility
*/
- public function setTitle($title) {
+ public function setTitle(string $title) {
$this->title = $title;
return $this;
*
* @return string
*/
- public function getTitle() {
+ public function getTitle(): ?string {
return $this->title;
}
*
* @return Civility
*/
- public function setCreated($created) {
+ public function setCreated(\DateTime $created) {
$this->created = $created;
return $this;
*
* @return \DateTime
*/
- public function getCreated() {
+ public function getCreated(): \DateTime {
return $this->created;
}
*
* @return Civility
*/
- public function setUpdated($updated) {
+ public function setUpdated(\DateTime $updated) {
$this->updated = $updated;
return $this;
*
* @return \DateTime
*/
- public function getUpdated() {
+ public function getUpdated(): \DateTime {
return $this->updated;
}
/**
* Add user
*
- * @param \Rapsys\UserBundle\Entity\User $user
+ * @param User $user
*
* @return Civility
*/
- public function addUser(\Rapsys\UserBundle\Entity\User $user) {
+ public function addUser(User $user): Civility {
$this->users[] = $user;
return $this;
/**
* Remove user
*
- * @param \Rapsys\UserBundle\Entity\User $user
+ * @param User $user
*/
- public function removeUser(\Rapsys\UserBundle\Entity\User $user) {
+ public function removeUser(User $user) {
$this->users->removeElement($user);
}
/**
* Get users
*
- * @return \Doctrine\Common\Collections\Collection
+ * @return ArrayCollection
*/
- public function getUsers() {
+ public function getUsers(): ArrayCollection {
return $this->users;
}
-<?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/UserBundle/Entity/Group.php
namespace Rapsys\UserBundle\Entity;
+use Doctrine\Common\Collections\ArrayCollection;
+
+use Rapsys\UserBundle\Entity\User;
+
+/**
+ * Group
+ */
class Group {
/**
* @var integer
protected $updated;
/**
- * @var \Doctrine\Common\Collections\Collection
+ * @var ArrayCollection
*/
protected $users;
*/
public function __construct(string $title) {
$this->title = (string) $title;
- $this->users = new \Doctrine\Common\Collections\ArrayCollection();
+ $this->users = new ArrayCollection();
}
/**
*
* @return integer
*/
- public function getId() {
+ public function getId(): int {
return $this->id;
}
*
* @return User
*/
- public function setTitle($title) {
+ public function setTitle(string $title) {
$this->title = $title;
return $this;
*
* @return string
*/
- public function getTitle() {
+ public function getTitle(): ?string {
return $this->title;
}
*
* @return User
*/
- public function setCreated($created) {
+ public function setCreated(\DateTime $created) {
$this->created = $created;
return $this;
*
* @return \DateTime
*/
- public function getCreated() {
+ public function getCreated(): \DateTime {
return $this->created;
}
*
* @return User
*/
- public function setUpdated($updated) {
+ public function setUpdated(\DateTime $updated) {
$this->updated = $updated;
return $this;
*
* @return \DateTime
*/
- public function getUpdated() {
+ public function getUpdated(): \DateTime {
return $this->updated;
}
/**
* Add user
*
- * @param \Rapsys\UserBundle\Entity\User $user
+ * @param User $user
*
* @return Group
*/
- public function addUser(\Rapsys\UserBundle\Entity\User $user) {
+ public function addUser(User $user) {
$this->users[] = $user;
return $this;
/**
* Remove user
*
- * @param \Rapsys\UserBundle\Entity\User $user
+ * @param User $user
*/
- public function removeUser(\Rapsys\UserBundle\Entity\User $user) {
+ public function removeUser(User $user) {
$this->users->removeElement($user);
}
/**
* Get users
*
- * @return \Doctrine\Common\Collections\Collection
+ * @return ArrayCollection
*/
- public function getUsers() {
+ public function getUsers(): ArrayCollection {
return $this->users;
}
*
* @return string
*/
- public function getRole() {
+ public function getRole(): string {
return 'ROLE_'.strtoupper($this->title);
}
}
-<?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/UserBundle/Entity/User.php
namespace Rapsys\UserBundle\Entity;
-use Rapsys\UserBundle\Entity\Group;
-use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Common\Collections\ArrayCollection;
+use Symfony\Component\Security\Core\User\UserInterface;
+
use Rapsys\UserBundle\Entity\Civility;
+use Rapsys\UserBundle\Entity\Group;
+/**
+ * User
+ */
class User implements UserInterface, \Serializable {
/**
* @var integer
protected $updated;
/**
- * @var \Rapsys\UserBundle\Entity\Civility
+ * @var Civility
*/
protected $civility;
/**
- * @var \Doctrine\Common\Collections\ArrayCollection
+ * @var ArrayCollection
*/
protected $groups;
/**
* Add group
*
- * @param \Rapsys\UserBundle\Entity\Group $group
+ * @param Group $group
*
* @return User
*/
/**
* Remove group
*
- * @param \Rapsys\UserBundle\Entity\Group $group
+ * @param Group $group
*/
public function removeGroup(Group $group) {
$this->groups->removeElement($group);
/**
* Get groups
*
- * @return \Doctrine\Common\Collections\ArrayCollection
+ * @return ArrayCollection
*/
public function getGroups(): ArrayCollection {
return $this->groups;