initial commit
[namibia] / module / Statistical / src / Statistical / Entity / Statistical.php
1 <?php
2 namespace Statistical\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * Statistical almost sound like a stat + test and a tickle, lol.
10  * @ORM\Entity
11  * @ORM\Table(name="lib_statistical")
12  */
13 class Statistical
14 {
15
16         /**
17          * Can not archive records.
18          */
19         const ARCHIVE = false;
20         /**
21          * Pull Synchronization Strategy for this table.
22          */
23         const PULL_SYNCH_STRATEGY = 'Build';
24         /**
25          * Push Synchronization Strategy for this table.
26          */
27         const PUSH_SYNCH_STRATEGY = 'Build';
28
29
30         /**
31          * @ORM\Id
32          * @ORM\Column(type="integer");
33          * @ORM\GeneratedValue(strategy="AUTO")
34          */
35         protected $id;
36
37         
38         /* ------------------------------------ Ownership ------------------------------------ */
39         /**
40          * @ORM\ManyToOne(targetEntity="\Stock\Entity\Stock", cascade={"all"})
41          * @ORM\JoinColumn(nullable=false, name="stock_id")
42          **/
43         protected $stock;
44         
45         
46         /* ------------------------------------ Stats ------------------------------------ */
47         /**
48          * @ORM\Column(type="boolean", nullable=true, name="deal_done");
49          */
50         protected $dealdone;
51         
52         
53         /**
54          * @ORM\Column(type="boolean", nullable=true, name="deal_not_done");
55          */
56         protected $dealnotdone;
57         
58         
59         /**
60          * @ORM\Column(type="boolean", nullable=true, name="trade_centre");
61          */
62         protected $tradecentre;
63         
64         /**
65          * @ORM\ManyToOne(targetEntity="\User\Entity\Profile")
66          * @ORM\JoinColumn(nullable=true, name="from_profile_id")
67          **/
68         protected $fromProfile;
69         
70         /**
71          * @ORM\Column(type="datetime");
72          */
73         protected $created;
74
75         
76         /**
77          * Initialize collections.
78          */
79         public function __construct()
80         {
81                 $this->stock = new \Doctrine\Common\Collections\ArrayCollection();
82         }
83
84         /**
85          * Magic getter to expose protected properties.
86          * @param string $property
87          * @return mixed
88          */
89         public function __get($property)
90         {
91                 return $this->$property;
92         }
93
94         /**
95          * Magic setter to save protected properties.
96          * @param string $property
97          * @param mixed $value
98          */
99         public function __set($property, $value)
100         {
101                 $this->$property = $value;
102         }
103                 
104         
105         /**
106          * @ORM\PrePersist
107          */
108         public function setCreateTime()
109         {
110                 $this->created = new \DateTime("now");
111         }
112         /**
113          * Convert the object to an array.
114          * @param array $expand
115          * @param array $intersect
116          * @return array
117          */
118         public function toArray(array $expand = array(), array $intersect = array())
119         {
120                 $includeAll = empty($intersect);
121                 $data = array();
122                 ($includeAll || isset($intersect['id']))
123                         && $data['id'] = $this->id;
124                 ($includeAll || isset($intersect['stock']))
125                         && $data['stock'] = $this->stock;
126                 ($includeAll || isset($intersect['dealdone']))
127                         && $data['dealdone'] = $this->dealdone;
128                 ($includeAll || isset($intersect['dealnotdone']))
129                         && $data['dealnotdone'] = $this->dealnotdone;
130                 ($includeAll || isset($intersect['tradecentre']))
131                         && $data['tradecentre'] = $this->tradecentre;
132                 ($includeAll || isset($intersect['fromProfile']))
133                         && $data['fromProfile'] = in_array('fromProfile', $expand)
134                         && !is_null($this->fromProfile)
135                                 ? $this->fromProfile->toArray($expand, $intersect)
136                                 : null;
137                 ($includeAll || isset($intersect['created']))
138                         && $data['created'] = $this->created;
139                 return $data;
140         }
141
142         /**
143          * Convert the object to an array for synchronization.
144          * @return array
145          */
146         public function toSynchArray()
147         {
148                 return array(
149                                 'id'                    => $this->id,
150                                 'stock'                 => $this->stock,
151                                 'dealdone'              => $this->dealdone,
152                                 'dealnotdone'   => $this->dealnotdone,
153                                 'tradecentre'   => $this->tradecentre,
154                                 'fromProfile'   => $this->fromProfile,
155                                 'created'               => $this->created
156                 );
157         }
158
159         /**
160          * Populate from an array.
161          * @param array $data
162          */
163         public function fromArray($data = array())
164         {
165                 isset($data['id'])
166                         && $this->id = $data['id'];
167                 isset($data['stock'])
168                         && $this->stock  = $data['stock'];
169                 isset($data['dealdone'])
170                         && $this->dealdone  = $data['dealdone'];
171                 isset($data['dealnotdone'])
172                         && $this->dealnotdone  = $data['dealnotdone'];
173                 isset($data['tradecentre'])
174                         && $this->tradecentre  = $data['tradecentre'];
175                 isset($data['fromProfile'])
176                         && $this->fromProfile = $data['fromProfile'];
177                 isset($data['created'])
178                         && $this->created  = $data['created'];
179         }
180
181 }