| Total Complexity | 6 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 28.57% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | trait DataTrait |
||
| 8 | { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @var string |
||
| 12 | */ |
||
| 13 | protected $path; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | protected $data; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param array|Slice $data |
||
| 22 | * |
||
| 23 | * @return array |
||
| 24 | */ |
||
| 25 | protected function _fromArray($data) |
||
| 26 | { |
||
| 27 | if ($data instanceof Slice) |
||
| 28 | { |
||
| 29 | return $data->asArray(); |
||
| 30 | } |
||
| 31 | |||
| 32 | return $data; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * DataTrait constructor. |
||
| 37 | * |
||
| 38 | * @param array|Slice|string $data |
||
| 39 | */ |
||
| 40 | 4 | public function __construct($data) |
|
| 41 | { |
||
| 42 | 4 | if (\is_string($data)) |
|
| 43 | { |
||
| 44 | 4 | $this->path = $data; |
|
| 45 | 4 | return; |
|
| 46 | } |
||
| 47 | |||
| 48 | $this->data = $this->_fromArray($data); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @inheritdoc |
||
| 53 | */ |
||
| 54 | public function asSlice($parameters = null) |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | public function path() |
||
| 65 | } |
||
| 66 | |||
| 68 |