2015-04-07 19:11:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Pays
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var integer $id Identifiant du pays
|
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string $nom Nom du pays
|
|
|
|
*/
|
|
|
|
protected $nom;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string $symbole Symbole du pays
|
|
|
|
*/
|
|
|
|
protected $symbole;
|
|
|
|
|
2015-04-07 19:33:21 +02:00
|
|
|
/**
|
|
|
|
* @var mixed[] $participants Participants
|
|
|
|
*/
|
|
|
|
protected $participants = [];
|
|
|
|
|
2015-04-07 19:56:16 +02:00
|
|
|
/**
|
|
|
|
* @var mixed[] $videos Vidéos
|
|
|
|
*/
|
|
|
|
protected $videos = [];
|
|
|
|
|
2015-04-07 19:11:26 +02:00
|
|
|
/**
|
|
|
|
* @param string $nom Nom du pays
|
|
|
|
* @param string $symbole Symbole du pays
|
|
|
|
*/
|
|
|
|
public function __construct($nom, $symbole = null)
|
|
|
|
{
|
|
|
|
$this->setNom($nom);
|
|
|
|
|
|
|
|
if (null !== $symbole) {
|
|
|
|
$this->setSymbole($symbole);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-04-07 19:22:42 +02:00
|
|
|
* @param integer|null $id
|
2015-04-07 19:11:26 +02:00
|
|
|
* @return Pays
|
|
|
|
*/
|
|
|
|
public function setId($id)
|
|
|
|
{
|
|
|
|
$this->id = (int) $id;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return integer|null
|
|
|
|
*/
|
|
|
|
public function getId()
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $nom
|
|
|
|
* @return Pays
|
|
|
|
*/
|
|
|
|
public function setNom($nom)
|
|
|
|
{
|
|
|
|
if ('' === trim((string) $nom)) {
|
|
|
|
throw new InvalidArgumentException('Le nom ne peut pas être vide.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->nom = $nom;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getNom()
|
|
|
|
{
|
|
|
|
return $this->nom;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $symbole
|
|
|
|
* @return Pays
|
|
|
|
*/
|
|
|
|
public function setSymbole($symbole)
|
|
|
|
{
|
|
|
|
if ('' === trim((string) $symbole)) {
|
|
|
|
throw new InvalidArgumentException('Le symbole ne peut pas être vide.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->symbole = $symbole;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getSymbole()
|
|
|
|
{
|
|
|
|
return $this->symbole;
|
|
|
|
}
|
2015-04-07 19:33:21 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Pays
|
|
|
|
*/
|
|
|
|
public function addParticipant(Participant $participant)
|
|
|
|
{
|
|
|
|
foreach ($this->getParticipants() as $p) {
|
|
|
|
if ($p === $participant) {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-07 19:56:16 +02:00
|
|
|
if ($this !== $participant->getPays()) {
|
|
|
|
$participant->setPays($this);
|
|
|
|
}
|
|
|
|
|
2015-04-07 19:33:21 +02:00
|
|
|
$this->participants[] = $participant;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed[] $participants
|
|
|
|
* @return Pays
|
|
|
|
*/
|
|
|
|
public function setParticipants(array $participants)
|
|
|
|
{
|
2015-04-07 19:56:16 +02:00
|
|
|
$this->participants = [];
|
|
|
|
|
|
|
|
foreach ($participants as $participant) {
|
|
|
|
$this->addParticipant($participant);
|
|
|
|
}
|
2015-04-07 19:33:21 +02:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getParticipants()
|
|
|
|
{
|
|
|
|
return $this->participants;
|
|
|
|
}
|
2015-04-07 19:56:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Video $video
|
|
|
|
* @return boolean Le pays est associé à la vidéo
|
|
|
|
*/
|
|
|
|
public function hasVideo(Video $video)
|
|
|
|
{
|
|
|
|
foreach ($this->getVideos() as $p) {
|
|
|
|
if ($p === $video) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Pays
|
|
|
|
*/
|
|
|
|
public function addVideo(Video $video)
|
|
|
|
{
|
|
|
|
if ($this->hasVideo($video)) {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
$video->addPays($this);
|
|
|
|
|
|
|
|
$this->videos[] = $video;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed[] $videos
|
|
|
|
* @return Pays
|
|
|
|
*/
|
|
|
|
public function setVideos(array $videos)
|
|
|
|
{
|
|
|
|
$this->videos = [];
|
|
|
|
|
|
|
|
foreach ($this->getVideos() as $v) {
|
|
|
|
$this->addVideo($v);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getVideos()
|
|
|
|
{
|
|
|
|
return $this->videos;
|
|
|
|
}
|
2015-04-07 19:11:26 +02:00
|
|
|
}
|