Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / Models / StockExchange / Market.php
1 <?php
2
3 namespace Doctrine\Tests\Models\StockExchange;
4
5 use Doctrine\Common\Collections\ArrayCollection;
6
7 /**
8  * @Entity
9  * @Table(name="exchange_markets")
10  */
11 class Market
12 {
13     /**
14      * @Id @Column(type="integer") @GeneratedValue
15      * @var int
16      */
17     private $id;
18
19     /**
20      * @Column(type="string")
21      * @var string
22      */
23     private $name;
24
25     /**
26      * @OneToMany(targetEntity="Stock", mappedBy="market", indexBy="symbol")
27      * @var Stock[]
28      */
29     public $stocks;
30
31     public function __construct($name)
32     {
33         $this->name = $name;
34         $this->stocks = new ArrayCollection();
35     }
36
37     public function getId()
38     {
39         return $this->id;
40     }
41
42     public function getName()
43     {
44         return $this->name;
45     }
46
47     public function addStock(Stock $stock)
48     {
49         $this->stocks[$stock->getSymbol()] = $stock;
50     }
51
52     public function getStock($symbol)
53     {
54         return $this->stocks[$symbol];
55     }
56 }