1: <?php
2:
3: namespace PHPixie\ORM\Relationships\Type\Embeds\Type\One\Property\Entity;
4:
5: class Item extends \PHPixie\ORM\Relationships\Type\Embeds\Property\Entity
6: {
7:
8: public function create($data = null)
9: {
10: $config = $this->side->config();
11: $this->handler->createItem($this->entity, $config, $data);
12: return $this->value();
13: }
14:
15: public function set($item)
16: {
17: if($item === null)
18: return $this->remove();
19:
20: $config = $this->side->config();
21: $this->handler->setItem($this->entity, $config, $item);
22: return $this;
23: }
24:
25: public function exists()
26: {
27: return $this->value() !== null;
28: }
29:
30: public function remove()
31: {
32: $config = $this->side->config();
33: $this->handler->removeItem($this->entity, $config);
34: return $this;
35: }
36:
37: public function asData($recursive = false)
38: {
39: $value = $this->value();
40: if ($value === null)
41: return null;
42:
43: return $value->asObject($recursive);
44: }
45: }
46: