src/CurrencyBundle/Entity/ExchangeRate.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\CurrencyBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Doctrine\ORM\Mapping\UniqueConstraint;
  5. use PN\ServiceBundle\Interfaces\DateTimeInterface;
  6. use PN\ServiceBundle\Model\DateTimeTrait;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9. * @ORM\HasLifecycleCallbacks
  10. * @ORM\Table("exchange_rate", uniqueConstraints={
  11. * @UniqueConstraint(name="exchange_unique", columns={"source_currency_id", "target_currency_id"})
  12. * }
  13. * )
  14. * @ORM\Entity(repositoryClass="App\CurrencyBundle\Repository\ExchangeRateRepository")
  15. */
  16. class ExchangeRate implements DateTimeInterface
  17. {
  18. use DateTimeTrait;
  19. /**
  20. * @ORM\Column(name="id", type="integer")
  21. * @ORM\Id
  22. * @ORM\GeneratedValue(strategy="AUTO")
  23. */
  24. private ?int $id;
  25. /**
  26. * @ORM\ManyToOne(targetEntity="App\CurrencyBundle\Entity\Currency")
  27. */
  28. private ?Currency $sourceCurrency;
  29. /**
  30. * @ORM\ManyToOne(targetEntity="App\CurrencyBundle\Entity\Currency")
  31. */
  32. private ?Currency $targetCurrency;
  33. /**
  34. * @var float
  35. *
  36. * @Assert\NotBlank()
  37. * @ORM\Column(name="ratio", type="float")
  38. */
  39. private float $ratio;
  40. public function getId(): ?int
  41. {
  42. return $this->id;
  43. }
  44. public function getRatio(): ?string
  45. {
  46. return $this->ratio;
  47. }
  48. public function setRatio(string $ratio): self
  49. {
  50. $this->ratio = $ratio;
  51. return $this;
  52. }
  53. public function getSourceCurrency(): ?Currency
  54. {
  55. return $this->sourceCurrency;
  56. }
  57. public function setSourceCurrency(?Currency $sourceCurrency): self
  58. {
  59. $this->sourceCurrency = $sourceCurrency;
  60. return $this;
  61. }
  62. public function getTargetCurrency(): ?Currency
  63. {
  64. return $this->targetCurrency;
  65. }
  66. public function setTargetCurrency(?Currency $targetCurrency): self
  67. {
  68. $this->targetCurrency = $targetCurrency;
  69. return $this;
  70. }
  71. }