1 <?php 
declare(strict_types
=1); 
   4  * This file is part of the Rapsys UserBundle package. 
   6  * (c) Raphaël Gertz <symfony@rapsys.eu> 
   8  * For the full copyright and license information, please view the LICENSE 
   9  * file that was distributed with this source code. 
  12 namespace Rapsys\UserBundle\Entity
; 
  14 use Doctrine\Common\Collections\ArrayCollection
; 
  15 use Doctrine\ORM\Event\PreUpdateEventArgs
; 
  17 use Rapsys\UserBundle\Entity\User
; 
  44          * @var ArrayCollection 
  51          * @param string $title The civility name 
  53         public function __construct(string $title) { 
  55                 $this->title 
= $title; 
  56                 $this->created 
= new \
DateTime('now'); 
  57                 $this->updated 
= new \
DateTime('now'); 
  58                 $this->users 
= new ArrayCollection(); 
  66         public function getId(): int { 
  73          * @param string $title 
  77         public function setTitle(string $title): Civility 
{ 
  78                 $this->title 
= $title; 
  88         public function getTitle(): ?string { 
  95          * @param \DateTime $created 
  99         public function setCreated(\DateTime 
$created): Civility 
{ 
 100                 $this->created 
= $created; 
 110         public function getCreated(): \DateTime 
{ 
 111                 return $this->created
; 
 117          * @param \DateTime $updated 
 121         public function setUpdated(\DateTime 
$updated): Civility 
{ 
 122                 $this->updated 
= $updated; 
 132         public function getUpdated(): \DateTime 
{ 
 133                 return $this->updated
; 
 143         public function addUser(User 
$user): Civility 
{ 
 144                 $this->users
[] = $user; 
 154         public function removeUser(User 
$user) { 
 155                 $this->users
->removeElement($user); 
 161          * @return ArrayCollection 
 163         public function getUsers(): ArrayCollection 
{ 
 170         public function preUpdate(PreUpdateEventArgs 
$eventArgs) { 
 171                 //Check that we have a civility instance 
 172                 if (($user = $eventArgs->getObject()) instanceof Civility
) { 
 174                         $user->setUpdated(new \
DateTime('now')); 
 179          * Returns a string representation of the title 
 183         public function __toString(): string {