| Conditions | 8 | 
| Paths | 6 | 
| Total Lines | 33 | 
| Code Lines | 18 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 19 | 
| CRAP Score | 8 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 25 | 5 | public static function fromLevelOrderList(array $list, callable $nodeCreator): ?Node  | 
            |
| 26 |     { | 
            ||
| 27 | 5 | $tailIdx = count($list) - 1;  | 
            |
| 28 | 5 |         if ($tailIdx < 0 || (0 === $tailIdx && null === $list[0])) { | 
            |
| 29 | 2 | return null;  | 
            |
| 30 | }  | 
            ||
| 31 | |||
| 32 | /** @var SplQueue<Node> $queue */  | 
            ||
| 33 | 3 | $queue = new SplQueue();  | 
            |
| 34 | |||
| 35 | 3 | $root = call_user_func($nodeCreator, $list[0]); // @phpstan-ignore argument.type  | 
            |
| 36 | 3 | $queue->enqueue($root);  | 
            |
| 37 | |||
| 38 | 3 | $idx = 1; // Root value already managed, hence 1 rather 0 !  | 
            |
| 39 | 3 |         while ($idx <= $tailIdx) { | 
            |
| 40 | 3 | $parentNode = $queue->dequeue();  | 
            |
| 41 | |||
| 42 | // 1. Manage left node value  | 
            ||
| 43 | 3 |             if (null !== $list[$idx]) { | 
            |
| 44 | 3 | $parentNode->left = $node = call_user_func($nodeCreator, $list[$idx]);  | 
            |
| 45 | 3 | $queue->enqueue($node);  | 
            |
| 46 | }  | 
            ||
| 47 | 3 | ++$idx;  | 
            |
| 48 | |||
| 49 | // 1. Manage right node value (if it exists !)  | 
            ||
| 50 | 3 |             if ($idx <= $tailIdx && null !== $list[$idx]) { | 
            |
| 51 | 3 | $parentNode->right = $node = call_user_func($nodeCreator, $list[$idx]);  | 
            |
| 52 | 3 | $queue->enqueue($node);  | 
            |
| 53 | }  | 
            ||
| 54 | 3 | ++$idx;  | 
            |
| 55 | }  | 
            ||
| 56 | |||
| 57 | 3 | return $root;  | 
            |
| 58 | }  | 
            ||
| 60 |