src/FMT/Domain/Type/Payment/Donation.php line 15

Open in your IDE?
  1. <?php
  2. /**
  3.  * Author: Anton Orlov
  4.  * Date: 23.04.2018
  5.  * Time: 13:10
  6.  */
  7. namespace FMT\Domain\Type\Payment;
  8. use FMT\Data\Entity\MinimalUserInterface;
  9. use FMT\Data\Entity\UnregisteredUserDto;
  10. use FMT\Data\Entity\User;
  11. use FMT\Domain\Service\PaymentProcessor\ProcessorInterface;
  12. class Donation
  13. {
  14.     /** @var User */
  15.     private $student;
  16.     /** @var MinimalUserInterface */
  17.     private $donor;
  18.     /** @var bool */
  19.     private $anonymous true;
  20.     /** @var float */
  21.     private $paymentAmount;
  22.     /** @var ProcessorInterface */
  23.     private $paymentProcessor;
  24.     public function __construct(?User $student)
  25.     {
  26.         $this->student $student;
  27.     }
  28.     /**
  29.      * @return User
  30.      */
  31.     public function getStudent()
  32.     {
  33.         return $this->student;
  34.     }
  35.     /**
  36.      * @param User $student
  37.      * @return $this
  38.      */
  39.     public function setStudent(User $student)
  40.     {
  41.         $this->student $student;
  42.         return $this;
  43.     }
  44.     /**
  45.      * @return MinimalUserInterface
  46.      */
  47.     public function getDonor()
  48.     {
  49.         return $this->donor;
  50.     }
  51.     /**
  52.      * @param User $donor
  53.      * @return $this
  54.      */
  55.     public function setDonor(User $donor null)
  56.     {
  57.         $this->donor $donor;
  58.         return $this;
  59.     }
  60.     /**
  61.      * @return string
  62.      */
  63.     public function getEmail()
  64.     {
  65.         return $this->donor $this->donor->getEmail(): null;
  66.     }
  67.     /**
  68.      * @param string $email
  69.      * @return $this
  70.      */
  71.     public function setEmail($email)
  72.     {
  73.         $this->createDonor()->setEmail($email);
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return string
  78.      */
  79.     public function getFirstName()
  80.     {
  81.         return $this->donor $this->donor->getFirstName() : null;
  82.     }
  83.     /**
  84.      * @param string $firstName
  85.      * @return $this
  86.      */
  87.     public function setFirstName($firstName)
  88.     {
  89.         $this->createDonor()->setFirstName($firstName);
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return string
  94.      */
  95.     public function getLastName()
  96.     {
  97.         return $this->donor $this->donor->getLastName() : null;
  98.     }
  99.     /**
  100.      * @param string $lastName
  101.      * @return $this
  102.      */
  103.     public function setLastName($lastName)
  104.     {
  105.         $this->createDonor()->setLastName($lastName);
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return boolean
  110.      */
  111.     public function isAnonymous()
  112.     {
  113.         return $this->anonymous;
  114.     }
  115.     /**
  116.      * @param boolean $anonymous
  117.      */
  118.     public function setAnonymous(bool $anonymous)
  119.     {
  120.         $this->anonymous $anonymous;
  121.     }
  122.     /**
  123.      * @return float
  124.      */
  125.     public function getPaymentAmount()
  126.     {
  127.         return $this->paymentAmount;
  128.     }
  129.     /**
  130.      * @return int
  131.      */
  132.     public function getPaymentAmountCents()
  133.     {
  134.         return (int)round($this->paymentAmount 100);
  135.     }
  136.     /**
  137.      * @param float $paymentAmount
  138.      */
  139.     public function setPaymentAmount(float $paymentAmount)
  140.     {
  141.         $this->paymentAmount $paymentAmount;
  142.     }
  143.     /**
  144.      * @return ProcessorInterface
  145.      */
  146.     public function getPaymentProcessor()
  147.     {
  148.         return $this->paymentProcessor;
  149.     }
  150.     /**
  151.      * @param ProcessorInterface $paymentProcessor
  152.      */
  153.     public function setPaymentProcessor(ProcessorInterface $paymentProcessor)
  154.     {
  155.         $this->paymentProcessor $paymentProcessor;
  156.     }
  157.     /**
  158.      * @return MinimalUserInterface
  159.      */
  160.     private function createDonor()
  161.     {
  162.         if (!$this->donor) {
  163.             $this->donor = new UnregisteredUserDto();
  164.         }
  165.         return $this->donor;
  166.     }
  167. }