| Conditions | 4 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace Arcanedev\LaravelNestedSet\Utilities; |
||
| 46 | 8 | protected static function reorderNodes( |
|
| 47 | array &$dictionary, |
||
| 48 | &$fixed, |
||
| 49 | $parentId = null, |
||
| 50 | $cut = 1 |
||
| 51 | ) { |
||
| 52 | 8 | if ( ! isset($dictionary[$parentId])) { |
|
| 53 | 8 | return $cut; |
|
| 54 | } |
||
| 55 | |||
| 56 | /** @var NodeTrait $model */ |
||
| 57 | 8 | foreach ($dictionary[$parentId] as $model) { |
|
| 58 | 8 | $lft = $cut; |
|
| 59 | 8 | $cut = self::reorderNodes($dictionary, $fixed, $model->getKey(), $cut + 1); |
|
| 60 | 8 | $rgt = $cut; |
|
| 61 | |||
| 62 | 8 | if ($model->rawNode($lft, $rgt, $parentId)->isDirty()) { |
|
| 63 | 8 | $model->save(); |
|
| 64 | 8 | $fixed++; |
|
| 65 | 6 | } |
|
| 66 | |||
| 67 | 8 | ++$cut; |
|
| 68 | 6 | } |
|
| 69 | |||
| 70 | 8 | unset($dictionary[$parentId]); |
|
| 71 | |||
| 72 | 8 | return $cut; |
|
| 73 | } |
||
| 74 | } |
||
| 75 |