Item   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 1
c 1
b 0
f 0
dl 0
loc 5
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A number() 0 3 2
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Parser\Helpers;
4
5
use Stratadox\Parser\Parser;
6
use Stratadox\Parser\Parsers\Map;
7
use function is_array;
8
9
/**
10
 * Item
11
 *
12
 * Transforms an array result into its nth item.
13
 */
14
final class Item
15
{
16
    public static function number(int|string $n, Parser $parser): Parser
17
    {
18
        return Map::the($parser, fn($x) => is_array($x) ? ($x[$n] ?? $x) : $x);
19
    }
20
}
21