<?phpnamespace DcSiteBundle\Entity;use Doctrine\Common\Collections\ArrayCollection;use CoreBundle\Entity\Dealer;use CoreBundle\Entity\Vehicles\Vehicle;use Doctrine\Common\Collections\Collection;/** * CreditProgram */class CreditProgram{ /** * @var integer */ private $id; /** * @var string */ private $bank; /** * @var integer */ private $state; /** * @var string */ private $params; /** * @var Collection */ private $dealer; /** * Constructor */ public function __construct() { $this->dealer = new ArrayCollection(); } public function __toString() { return $this->getBank().' | '.$this->getTitleUa(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set bank * * @param string $bank * * @return CreditProgram */ public function setBank($bank) { $this->bank = $bank; return $this; } /** * Get bank * * @return string */ public function getBank() { return $this->bank; } /** * Set state * * @param integer $state * * @return CreditProgram */ public function setState($state) { $this->state = $state; return $this; } /** * Get state * * @return integer */ public function getState() { return $this->state > 0; } /** * Set params * * @param string $params * * @return CreditProgram */ public function setParams($params) { $this->params = $params; return $this; } /** * Get params * * @return string */ public function getParams() { return $this->params; } /** * Add dealer * * @param Dealer $dealer * * @return CreditProgram */ public function addDealer(Dealer $dealer) { $this->dealer[] = $dealer; return $this; } /** * Remove dealer * * @param Dealer $dealer */ public function removeDealer(Dealer $dealer) { $this->dealer->removeElement($dealer); } /** * Get dealer * * @return Collection */ public function getDealer() { return $this->dealer; } /** * @var string */ private $title_ru; /** * @var string */ private $title_ua; /** * Set titleRu * * @param string $titleRu * * @return CreditProgram */ public function setTitleRu($titleRu) { $this->title_ru = $titleRu; return $this; } /** * Get titleRu * * @return string */ public function getTitleRu() { return $this->title_ru; } /** * Set titleUa * * @param string $titleUa * * @return CreditProgram */ public function setTitleUa($titleUa) { $this->title_ua = $titleUa; return $this; } /** * Get titleUa * * @return string */ public function getTitleUa() { return $this->title_ua; } /** * Get title * * @return string */ public function getTitle($locale) { return $locale == 'ru' ? $this->title_ru : $this->title_ua; } /** * @var integer */ private $minAvance; /** * @var integer */ private $maxTerm; /** * Set minAvance * * @param integer $minAvance * * @return CreditProgram */ public function setMinAvance($minAvance) { $this->minAvance = $minAvance; return $this; } /** * Get minAvance * * @return integer */ public function getMinAvance() { return $this->minAvance; } public function getMaxAvance() { return max(array_keys(json_decode($this->params,true))); } /** * Set maxTerm * * @param integer $maxTerm * * @return CreditProgram */ public function setMaxTerm($maxTerm) { $this->maxTerm = $maxTerm; return $this; } /** * Get maxTerm * * @return integer */ public function getMaxTerm() { return $this->maxTerm; } /** * @var integer */ private $maxAmount; /** * Set maxAmount * * @param integer $maxAmount * * @return CreditProgram */ public function setMaxAmount($maxAmount) { $this->maxAmount = $maxAmount; return $this; } /** * Get maxAmount * * @return integer */ public function getMaxAmount() { return $this->maxAmount; } /** * @var Vehicle */ private $vehicle; /** * Set vehicle * * @param Vehicle $vehicle * * @return CreditProgram */ public function setVehicle(Vehicle $vehicle = null) { $this->vehicle = $vehicle; return $this; } /** * Get vehicle * * @return Vehicle */ public function getVehicle() { return $this->vehicle; } /** * @var float */ private $addit_payment; /** * @var string */ private $addit_payment_comment; /** * @var float */ private $go_amount; /** * @var string */ private $casco_payment; /** * @var Collection */ private $vehicles; /** * Set additPayment * * @param float $additPayment * * @return CreditProgram */ public function setAdditPayment($additPayment) { $this->addit_payment = $additPayment; return $this; } /** * Get additPayment * * @return float */ public function getAdditPayment() { return $this->addit_payment; } /** * Set additPaymentComment * * @param string $additPaymentComment * * @return CreditProgram */ public function setAdditPaymentComment($additPaymentComment) { $this->addit_payment_comment = $additPaymentComment; return $this; } /** * Get additPaymentComment * * @return string */ public function getAdditPaymentComment() { return $this->addit_payment_comment; } /** * Set goAmount * * @param float $goAmount * * @return CreditProgram */ public function setGoAmount($goAmount) { $this->go_amount = $goAmount; return $this; } /** * Get goAmount * * @return float */ public function getGoAmount() { return $this->go_amount; } /** * Set cascoPayment * * @param string $cascoPayment * * @return CreditProgram */ public function setCascoPayment($cascoPayment) { $this->casco_payment = $cascoPayment; return $this; } /** * Get cascoPayment * * @return string */ public function getCascoPayment() { return $this->casco_payment; } /** * Add vehicle * * @param Vehicle $vehicle * * @return CreditProgram */ public function addVehicle(Vehicle $vehicle) { $this->vehicles[] = $vehicle; return $this; } /** * Remove vehicle * * @param Vehicle $vehicle */ public function removeVehicle(Vehicle $vehicle) { $this->vehicles->removeElement($vehicle); } /** * Get vehicles * * @return Collection */ public function getVehicles() { return $this->vehicles; } /** * @var float */ private $casco_payment_0; /** * @var float */ private $casco_payment_05; /** * @var float */ private $casco_payment_1; /** * Set cascoPayment0 * * @param float $cascoPayment0 * * @return CreditProgram */ public function setCascoPayment0($cascoPayment0) { $this->casco_payment_0 = $cascoPayment0; return $this; } /** * Get cascoPayment0 * * @return float */ public function getCascoPayment0() { return $this->casco_payment_0; } /** * Set cascoPayment05 * * @param float $cascoPayment05 * * @return CreditProgram */ public function setCascoPayment05($cascoPayment05) { $this->casco_payment_05 = $cascoPayment05; return $this; } /** * Get cascoPayment05 * * @return float */ public function getCascoPayment05() { return $this->casco_payment_05; } /** * Set cascoPayment1 * * @param float $cascoPayment1 * * @return CreditProgram */ public function setCascoPayment1($cascoPayment1) { $this->casco_payment_1 = $cascoPayment1; return $this; } /** * Get cascoPayment1 * * @return float */ public function getCascoPayment1() { return $this->casco_payment_1; } public function getCasco(): array { $arr = []; if ($this->casco_payment_0) { $arr['0'] = $this->casco_payment_0; } if ($this->casco_payment_05) { $arr['0.5'] = $this->casco_payment_05; } if ($this->casco_payment_1) { $arr['1'] = $this->casco_payment_1; } return $arr; } public function getMaxCasco(): array { $casco = []; if ($this->casco_payment_1) { $casco['1'] = $this->casco_payment_1; } elseif ($this->casco_payment_05) { $casco['0.5'] = $this->casco_payment_05; } else { $casco['0'] = $this->casco_payment_0; } return $casco; } /** * @var int|null */ private $for_used; /** * Set forUsed. * * @param int|null $forUsed * * @return CreditProgram */ public function setForUsed($forUsed = null) { $this->for_used = $forUsed; return $this; } /** * Get forUsed. * * @return int|null */ public function getForUsed() { return $this->for_used > 0; }}