| 1 | <?php |
||
| 5 | class Item implements IItem |
||
| 6 | {
|
||
| 7 | protected $url = ''; |
||
| 8 | |||
| 9 | protected $title = null; |
||
| 10 | |||
| 11 | protected $description = null; |
||
| 12 | |||
| 13 | |||
| 14 | 7 | public function __construct(array $data) |
|
| 15 | {
|
||
| 16 | 7 | $this->fromArray($data); |
|
| 17 | 7 | } |
|
| 18 | |||
| 19 | |||
| 20 | 7 | protected function fromArray(array $data) |
|
| 21 | {
|
||
| 22 | 7 | foreach($data as $key => $value) {
|
|
| 23 | if (property_exists($this, $key)) {
|
||
| 24 | $this->{$key} = $value;
|
||
| 25 | } |
||
| 26 | } |
||
| 27 | 7 | } |
|
| 28 | |||
| 29 | |||
| 30 | public function toArray() |
||
| 38 | |||
| 39 | |||
| 40 | public function __toString() |
||
| 44 | |||
| 45 | |||
| 46 | |||
| 47 | } |
||
| 48 |