2015-04-07 19:11:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Type
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var integer $id Identifiant du type
|
|
|
|
*/
|
|
|
|
protected $id;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string $lib Lib du type
|
|
|
|
*/
|
|
|
|
protected $lib;
|
|
|
|
|
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 $lib Lib du type
|
|
|
|
*/
|
|
|
|
public function __construct($lib)
|
|
|
|
{
|
|
|
|
$this->setLib($lib);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param integer $id
|
|
|
|
* @return Type
|
|
|
|
*/
|
|
|
|
public function setId($id)
|
|
|
|
{
|
|
|
|
$this->id = (int) $id;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return integer|null
|
|
|
|
*/
|
|
|
|
public function getId()
|
|
|
|
{
|
|
|
|
return $this->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $lib
|
|
|
|
* @return Type
|
|
|
|
*/
|
|
|
|
public function setLib($lib)
|
|
|
|
{
|
|
|
|
if ('' === trim((string) $lib)) {
|
|
|
|
throw new InvalidArgumentException('La lib ne peut pas être vide.');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->lib = $lib;
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getLib()
|
|
|
|
{
|
|
|
|
return $this->lib;
|
|
|
|
}
|
2015-04-07 19:56:16 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Video $video
|
|
|
|
* @return boolean Le type est associé à la vidéo
|
|
|
|
*/
|
|
|
|
public function hasVideo(Video $video)
|
|
|
|
{
|
|
|
|
foreach ($this->getVideos() as $p) {
|
|
|
|
if ($p === $video) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return Type
|
|
|
|
*/
|
|
|
|
public function addVideo(Video $video)
|
|
|
|
{
|
|
|
|
if ($this->hasVideo($video)) {
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->videos[] = $video;
|
|
|
|
|
2015-04-07 21:25:31 +02:00
|
|
|
$video->addType($this);
|
|
|
|
|
2015-04-07 19:56:16 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param mixed[] $videos
|
|
|
|
* @return Type
|
|
|
|
*/
|
|
|
|
public function setVideos(array $videos)
|
|
|
|
{
|
|
|
|
$this->videos = [];
|
|
|
|
|
2015-04-07 21:25:31 +02:00
|
|
|
foreach ($videos as $v) {
|
2015-04-07 19:56:16 +02:00
|
|
|
$this->addVideo($v);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-04-07 20:09:53 +02:00
|
|
|
/**
|
|
|
|
* @return mixed[] $videos
|
|
|
|
*/
|
2015-04-07 19:56:16 +02:00
|
|
|
public function getVideos()
|
|
|
|
{
|
|
|
|
return $this->videos;
|
|
|
|
}
|
2015-04-07 19:11:26 +02:00
|
|
|
}
|