Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| PathEntity | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
| getPath | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Satag\AmicronEntityBundle\Traits; |
| 6 | |
| 7 | trait PathEntity |
| 8 | { |
| 9 | public function getPath(string $separator = ' > '): ?string |
| 10 | { |
| 11 | $path = null; |
| 12 | $vater = $this->vater; |
| 13 | |
| 14 | while ($vater !== null) { |
| 15 | $path = $vater->getName() . $separator . $path; |
| 16 | if ($vater->vater !== null && $vater->vater !== $vater) { |
| 17 | $vater = $vater->vater; |
| 18 | } else { |
| 19 | $vater = null; |
| 20 | } |
| 21 | } |
| 22 | if ($path) { |
| 23 | $path = substr($path, 0, \strlen($separator) * -1); |
| 24 | } |
| 25 | |
| 26 | return $path; |
| 27 | } |
| 28 | } |