Join   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A the() 0 3 1
A with() 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 implode;
8
use function is_array;
9
10
/**
11
 * Join
12
 *
13
 * Implodes the array result into a string.
14
 */
15
final class Join
16
{
17
    public static function the(Parser|string $parser): Parser
18
    {
19
        return Join::with('', $parser);
20
    }
21
22
    public static function with(string $glue, Parser|string $parser): Parser
23
    {
24
        return Map::the($parser, fn($x) => is_array($x) ? implode($glue, $x) : $x);
25
    }
26
}
27