src/JuridicusBundle/Entity/Gebuehr.php line 12

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. /**
  7.  * Gebuehr
  8.  */
  9. class Gebuehr
  10. {
  11.     const CLASSNAME __CLASS__;
  12.     
  13.     const TYP_GRUNDGEBUEHR 1;
  14.     const TYP_WAHLFACHGEBUEHR 2;    
  15.     const TYP_STRAFGEBUEHR 3;
  16.     
  17.     /**
  18.      * @var array
  19.      */
  20.     
  21.     private static $typen = array(
  22.         self::TYP_GRUNDGEBUEHR => 'Grundgebühr',
  23.         self::TYP_WAHLFACHGEBUEHR => 'Wahlfachgebühr',
  24.         self::TYP_STRAFGEBUEHR => 'Strafgebühr'
  25.     ); 
  26.         
  27.     public static function getTypOptions()
  28.     {
  29.         return self::$typen;
  30.     }
  31.     
  32.     public static function getTypKeys()
  33.     {
  34.         return array_keys(self::$typen);
  35.     }    
  36.     
  37.     /**
  38.      * @var integer
  39.      */
  40.     private $id;
  41.     /**
  42.      * @var integer
  43.      * @Assert\Choice(callback = "getTypKeys")     
  44.      */
  45.     private $typ;
  46.     /**
  47.      * @var float
  48.      * @Assert\Range(min="0")
  49.      */
  50.     private $betrag;
  51.     /**
  52.      * @var \DateTime
  53.      * @Assert\Type(\DateTimeInterface::class)    
  54.      */
  55.     private $datum;
  56.     /**
  57.      * @var \Doctrine\Common\Collections\Collection
  58.      */
  59.     private $pruefungsaemter;
  60.     /**
  61.      * Get id
  62.      *
  63.      * @return integer 
  64.      */
  65.     public function getId()
  66.     {
  67.         return $this->id;
  68.     }
  69.     /**
  70.      * Set typ
  71.      *
  72.      * @param integer $typ
  73.      * @return Gebuehr
  74.      */
  75.     public function setTyp($typ)
  76.     {
  77.         $this->typ $typ;
  78.     
  79.         return $this;
  80.     }
  81.     /**
  82.      * Get typ
  83.      *
  84.      * @return integer 
  85.      */
  86.     public function getTyp()
  87.     {
  88.         return $this->typ;
  89.     }
  90.     /**
  91.      * Get typ_string
  92.      *
  93.      * @return string 
  94.      */
  95.     public function getTypString()
  96.     {
  97.         return self::$typen[$this->typ];
  98.     }
  99.     /**
  100.      * Set datum
  101.      *
  102.      * @param \DateTime $datum
  103.      * @return Gebuehr
  104.      */
  105.     public function setDatum(\DateTime $datum)
  106.     {
  107.         $this->datum $datum;                   
  108.         
  109.         return $this;
  110.     }
  111.     /**
  112.      * Get datum
  113.      *
  114.      * @return \DateTime 
  115.      */
  116.     public function getDatum()
  117.     {
  118.         return $this->datum;
  119.     }
  120.     
  121.     /**
  122.      * Set betrag
  123.      *
  124.      * @param float $betrag
  125.      * @return Gebuehr
  126.      */
  127.     public function setBetrag($betrag)
  128.     {
  129.         $this->betrag $betrag;
  130.     
  131.         return $this;
  132.     }
  133.     /**
  134.      * Get betrag
  135.      *
  136.      * @return float 
  137.      */
  138.     public function getBetrag()
  139.     {
  140.         return $this->betrag;
  141.     }
  142.     
  143.     public function __toString()
  144.     {
  145.         return ($this->betrag && $this->datum && self::$typen[$this->typ]) ? sprintf'%.2f € %s ab %s'$this->betragself::$typen[$this->typ], $this->datum->format('d.m.Y') ) : "";
  146.         //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') ) : "";
  147.     }
  148.  
  149.     /**
  150.      * Constructor
  151.      */
  152.     public function __construct()
  153.     {
  154.         $this->pruefungsaemter = new \Doctrine\Common\Collections\ArrayCollection();
  155.     }
  156.     
  157.     /**
  158.      * Add pruefungsaemter [INVERSE SIDE]
  159.      *
  160.      * @param \JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter
  161.      * @return Gebuehr
  162.      */
  163.     public function addPruefungsaemter(\JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter)
  164.     {
  165.         $this->pruefungsaemter[] = $pruefungsaemter;        
  166.         return $this;
  167.     }
  168.     /**
  169.      * Remove pruefungsaemter [INVERSE SIDE]
  170.      *
  171.      * @param \JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter
  172.      */
  173.     public function removePruefungsaemter(\JF\JuridicusBundle\Entity\Pruefungsamt $pruefungsaemter)
  174.     {
  175.         $this->pruefungsaemter->removeElement($pruefungsaemter);
  176.     }
  177.     /**
  178.      * Get pruefungsaemter
  179.      *
  180.      * @return \Doctrine\Common\Collections\Collection 
  181.      */
  182.     public function getPruefungsaemter()
  183.     {
  184.         return $this->pruefungsaemter;
  185.     }
  186. }