<?phpnamespace JF\JuridicusBundle\Entity;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\Validator\Constraints as Assert;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * Gebuehr */class Gebuehr{ const CLASSNAME = __CLASS__; const TYP_GRUNDGEBUEHR = 1; const TYP_WAHLFACHGEBUEHR = 2; const TYP_STRAFGEBUEHR = 3; /** * @var array */ private static $typen = array( self::TYP_GRUNDGEBUEHR => 'Grundgebühr', self::TYP_WAHLFACHGEBUEHR => 'Wahlfachgebühr', self::TYP_STRAFGEBUEHR => 'Strafgebühr' ); public static function getTypOptions() { return self::$typen; } public static function getTypKeys() { return array_keys(self::$typen); } /** * @var integer */ private $id; /** * @var integer * @Assert\Choice(callback = "getTypKeys") */ private $typ; /** * @var float * @Assert\Range(min="0") */ private $betrag; /** * @var \DateTime * @Assert\Type(\DateTimeInterface::class) */ private $datum; /** * @var \Doctrine\Common\Collections\Collection */ private $pruefungsaemter; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set typ * * @param integer $typ * @return Gebuehr */ public function setTyp($typ) { $this->typ = $typ; return $this; } /** * Get typ * * @return integer */ public function getTyp() { return $this->typ; } /** * Get typ_string * * @return string */ public function getTypString() { return self::$typen[$this->typ]; } /** * Set datum * * @param \DateTime $datum * @return Gebuehr */ public function setDatum(\DateTime $datum) { $this->datum = $datum; return $this; } /** * Get datum * * @return \DateTime */ public function getDatum() { return $this->datum; } /** * Set betrag * * @param float $betrag * @return Gebuehr */ public function setBetrag($betrag) { $this->betrag = $betrag; return $this; } /** * Get betrag * * @return float */ public function getBetrag() { return $this->betrag; } public function __toString() { return ($this->betrag && $this->datum && self::$typen[$this->typ]) ? sprintf( '%.2f € %s ab %s', $this->betrag, self::$typen[$this->typ], $this->datum->format('d.m.Y') ) : ""; //return ($this->betrag && $this->datum && in_array($this->typ, self::$typen)) ? sprintf( '%.2f € %s ab %s', $this->betrag, $this->typ, $this->datum->format('d.m.Y') ) : ""; } /** * Constructor */ public function __construct() { $this->pruefungsaemter = new \Doctrine\Common\Collections\ArrayCollection(); } /** * Add pruefungsaemter [INVERSE SIDE] * * @param \JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter * @return Gebuehr */ public function addPruefungsaemter(\JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter) { $this->pruefungsaemter[] = $pruefungsaemter; return $this; } /** * Remove pruefungsaemter [INVERSE SIDE] * * @param \JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter */ public function removePruefungsaemter(\JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter) { $this->pruefungsaemter->removeElement($pruefungsaemter); } /** * Get pruefungsaemter * * @return \Doctrine\Common\Collections\Collection */ public function getPruefungsaemter() { return $this->pruefungsaemter; }}