Stock.php 960B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Doctrine\Tests\Models\StockExchange;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. /**
  5. * @Entity
  6. * @Table(name="exchange_stocks")
  7. */
  8. class Stock
  9. {
  10. /**
  11. * @Id @GeneratedValue @Column(type="integer")
  12. * @var int
  13. */
  14. private $id;
  15. /**
  16. * For real this column would have to be unique=true. But I want to test behavior of non-unique overrides.
  17. *
  18. * @Column(type="string")
  19. */
  20. private $symbol;
  21. /**
  22. * @Column(type="decimal")
  23. */
  24. private $price;
  25. /**
  26. * @ManyToOne(targetEntity="Market", inversedBy="stocks")
  27. * @var Market
  28. */
  29. private $market;
  30. public function __construct($symbol, $initialOfferingPrice, Market $market)
  31. {
  32. $this->symbol = $symbol;
  33. $this->price = $initialOfferingPrice;
  34. $this->market = $market;
  35. $market->addStock($this);
  36. }
  37. public function getSymbol()
  38. {
  39. return $this->symbol;
  40. }
  41. }