1: <?php
2:
3: namespace PHPixie\Slice\Type;
4:
5: class Slice extends \PHPixie\Slice\Data\Implementation
6: {
7: protected $data;
8: protected $path;
9:
10: public function __construct($sliceBuilder, $data = null, $path = null)
11: {
12: $this->data = $data;
13: $this->path = $path;
14: parent::__construct($sliceBuilder);
15: }
16:
17: public function getData($path = null, $isRequired = false, $default = null)
18: {
19: $path = $this->dataPath($path);
20: return $this->data->getData($path, $isRequired, $default);
21: }
22:
23: public function slice($path = null)
24: {
25: return $this->data->slice($this->dataPath($path));
26: }
27:
28: public function arraySlice($path = null)
29: {
30: return $this->data->arraySlice($this->dataPath($path));
31: }
32:
33: public function keys($path = null, $isRequired = false)
34: {
35: return $this->data->keys($this->dataPath($path), $isRequired);
36: }
37:
38: public function path($path = null)
39: {
40: $path = $this->dataPath($path);
41:
42: if($this->data instanceof \PHPixie\Slice\Data\Slice) {
43: $path = $this->data->path($path);
44: }
45:
46: return $path;
47: }
48:
49: public function getIterator()
50: {
51: return $this->sliceBuilder->iterator($this);
52: }
53:
54: protected function dataPath($path)
55: {
56: return $this->mergePath($this->path, $path);
57: }
58: }
59: