<?php
namespace Uniski\ResourceBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Uniski\CommerceBundle\Exception\PriceNotFoundException;
/**
* @ORM\Entity
**/
class InsuranceRate extends PriceRate
{
const PRICE_MAIN_KEY = 'prices';
/**
* @var \Doctrine\Common\Collections\ArrayCollection
* @ORM\ManyToOne(targetEntity="Uniski\ConfigBundle\Entity\Category")
*
*/
protected $zone;
/**
* @var Insurance
* @ORM\ManyToOne(targetEntity="Insurance", inversedBy="rates")
*
*/
protected $insurance;
/**
* Set zone
*
* @param \Uniski\ConfigBundle\Entity\Category $zone
*
* @return InsuranceRate
*/
public function setZone(\Uniski\ConfigBundle\Entity\Category $zone = null)
{
$this->zone = $zone;
return $this;
}
/**
* Get zone
*
* @return \Uniski\ConfigBundle\Entity\Category
*/
public function getZone()
{
return $this->zone;
}
/**
* Set insurance
*
* @param \Uniski\ResourceBundle\Entity\Insurance $insurance
*
* @return InsuranceRate
*/
public function setInsurance(\Uniski\ResourceBundle\Entity\Insurance $insurance = null)
{
$this->insurance = $insurance;
return $this;
}
/**
* Get insurance
*
* @return \Uniski\ResourceBundle\Entity\Insurance
*/
public function getInsurance()
{
return $this->insurance;
}
public static function getModel($options = null)
{
$days = [1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '',
7 => '', 8 => '', 9 => '', 10 => '', 11 => '', 12 => '',
13 => '', 14 => '', 15 => '', 16 => ''];
return [
self::PRICE_MAIN_KEY => $days
];
}
public function getPrice($days)
{
if ($this->prices != null && isset($this->prices[self::PRICE_MAIN_KEY][$days])) return $this->prices[self::PRICE_MAIN_KEY][$days];
throw new PriceNotFoundException();
}
}