| Total Complexity | 9 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | trait LTreeTrait |
||
| 16 | { |
||
| 17 | public function getLtreeParentColumn(): string |
||
| 20 | } |
||
| 21 | |||
| 22 | public function getLtreePathColumn(): string |
||
| 23 | { |
||
| 24 | return 'path'; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function getLtreeParentId(): ?int |
||
| 28 | { |
||
| 29 | $value = $this->getAttribute($this->getLtreeParentColumn()); |
||
|
|
|||
| 30 | return $value ? (int) $value : null; |
||
| 31 | } |
||
| 32 | |||
| 33 | public function getLtreePath($mode = LTreeInterface::AS_ARRAY) |
||
| 34 | { |
||
| 35 | $path = $this->getAttribute($this->getLtreePathColumn()); |
||
| 36 | if ($mode === LTreeModelInterface::AS_ARRAY) { |
||
| 37 | return $path !== null ? explode(LTreeType::TYPE_SEPARATE, $path) : []; |
||
| 38 | } |
||
| 39 | return (string) $path; |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getLtreeLevel(): int |
||
| 45 | } |
||
| 46 | } |
||
| 47 |