Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / Models / StockExchange / Bond.php
1 <?php
2 namespace Doctrine\Tests\Models\StockExchange;
3
4 use Doctrine\Common\Collections\ArrayCollection;
5
6 /**
7  * Bonds have many stocks. This uses a many to many assocation and fails to model how many of a
8  * particular stock a bond has. But i Need a many-to-many assocation, so please bear with my modelling skills ;)
9  *
10  * @Entity
11  * @Table(name="exchange_bonds")
12  */
13 class Bond
14 {
15     /**
16      * @Id @GeneratedValue @column(type="integer")
17      * @var int
18      */
19     private $id;
20
21     /**
22      * @column(type="string")
23      * @var string
24      */
25     private $name;
26
27     /**
28      * @ManyToMany(targetEntity="Stock", indexBy="symbol")
29      * @JoinTable(name="exchange_bonds_stocks")
30      * @var Stock[]
31      */
32     public $stocks;
33
34     public function __construct($name)
35     {
36         $this->name = $name;
37     }
38
39     public function getId()
40     {
41         return $this->id;
42     }
43
44     public function addStock(Stock $stock)
45     {
46         $this->stocks[$stock->getSymbol()] = $stock;
47     }
48 }