click to refresh error debugging
[namibia] / module / Stock / src / Stock / Entity / Damage.php
1 <?php
2 namespace Stock\Entity;
3
4 use Doctrine\ORM\Mapping as ORM;
5
6
7
8 /**
9  * @ORM\Entity
10  * @ORM\Table(name="vehicle_damage", uniqueConstraints={@ORM\UniqueConstraint(name="unique_damage", columns={"name"})})
11  */
12 class Damage
13 {
14
15         /**
16          * Can archive records.
17          */
18         const ARCHIVE = true;
19         /**
20          * Pull Synchronization Strategy for this table.
21          */
22         const PULL_SYNCH_STRATEGY = 'Build';
23         /**
24          * Push Synchronization Strategy for this table.
25          */
26         const PUSH_SYNCH_STRATEGY = 'Build';
27
28
29         /**
30          * @ORM\Id
31          * @ORM\Column(type="integer");
32          * @ORM\GeneratedValue(strategy="AUTO")
33          */
34         protected $id;
35
36         /**
37          * @ORM\Column(type="string", length=20, unique=true)
38          */
39         protected $name;
40
41         /**
42          * @ORM\Column(type="boolean");
43          */
44         protected $archived = false;
45
46
47
48         /**
49          * Magic getter to expose protected properties.
50          * @param string $property
51          * @return mixed
52          */
53         public function __get($property)
54         {
55                 return $this->$property;
56         }
57
58         /**
59          * Magic setter to save protected properties.
60          * @param string $property
61          * @param mixed $value
62          */
63         public function __set($property, $value)
64         {
65                 $this->$property = $value;
66         }
67
68         /**
69          * Convert the object to an array.
70          * @param array $expand
71          * @param array $intersect
72          * @return array
73          */
74         public function toArray(array $expand = array(), array $intersect = array())
75         {
76                 !empty($intersect)
77                         && $intersect = array_flip($intersect);
78                 $includeAll = empty($intersect);
79                 $data = array();
80                 ($includeAll || isset($intersect['id']))
81                         && $data['id'] = $this->id;
82                 ($includeAll || isset($intersect['name']))
83                         && $data['name'] = $this->name;
84                 return $data;
85         }
86
87         /**
88          * Convert the object to an array for synchronization.
89          * @return array
90          */
91         public function toSynchArray()
92         {
93                 return array(
94                                 'id'   => $this->id,
95                                 'name' => $this->name
96                 );
97         }
98
99         /**
100          * Populate from an array.
101          * @param array $data
102          */
103         public function fromArray($data = array())
104         {
105                 isset($data['id'])
106                         && $this->id = $data['id'];
107                 isset($data['name'])
108                         && $this->name  = $data['name'];
109         }
110
111 }