1 <?php 
declare(strict_types
=1); 
   4  * This file is part of the Rapsys AirBundle 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\AirBundle\Entity
; 
  14 use Doctrine\Common\Collections\Collection
; 
  15 use Doctrine\Common\Collections\ArrayCollection
; 
  16 use Doctrine\ORM\Event\PreUpdateEventArgs
; 
  25         private ?int $id = null; 
  30         private \DateTime 
$created; 
  35         private \DateTime 
$updated; 
  40         private Collection 
$users; 
  45          * @param string $code The country code 
  46          * @param string $alpha The country alpha 
  47          * @param string $title The country title 
  49         public function __construct(private string $code, private string $alpha, private string $title) { 
  51                 $this->created 
= new \
DateTime('now'); 
  52                 $this->updated 
= new \
DateTime('now'); 
  55                 $this->users 
= new ArrayCollection(); 
  63         public function getId(): ?int { 
  74         public function setCode(string $code): Country 
{ 
  85         public function getCode(): string { 
  92          * @param string $alpha 
  96         public function setAlpha(string $alpha): Country 
{ 
  97                 $this->alpha 
= $alpha; 
 107         public function getAlpha(): string { 
 114          * @param string $title 
 118         public function setTitle(string $title): Country 
{ 
 119                 $this->title 
= $title; 
 129         public function getTitle(): string { 
 136          * @param \DateTime $created 
 140         public function setCreated(\DateTime 
$created): Country 
{ 
 141                 $this->created 
= $created; 
 151         public function getCreated(): \DateTime 
{ 
 152                 return $this->created
; 
 158          * @param \DateTime $updated 
 162         public function setUpdated(\DateTime 
$updated): Country 
{ 
 163                 $this->updated 
= $updated; 
 173         public function getUpdated(): \DateTime 
{ 
 174                 return $this->updated
; 
 184         public function addUser(User 
$user): User 
{ 
 185                 $this->users
[] = $user; 
 195         public function removeUser(User 
$user): bool { 
 196                 return $this->users
->removeElement($user); 
 202          * @return ArrayCollection 
 204         public function getUsers(): ArrayCollection 
{ 
 211         public function preUpdate(PreUpdateEventArgs 
$eventArgs) { 
 212                 //Check that we have an country instance 
 213                 if (($country = $eventArgs->getObject()) instanceof Country
) { 
 215                         $country->setUpdated(new \
DateTime('now')); 
 220          * Returns a string representation of the country 
 224         public function __toString(): string {