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