Passed
Push — master ( 1a8268...9cfe94 )
by Sebastian
08:09
created

Functions.php$0 ➔ isList()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Seboettg\Collection\Lists;
4
5
use Seboettg\Collection\Comparable\Comparable;
6
7
final class Functions
8
{
9
    final public static function emptyList(): ListInterface
10
    {
11
        return new class() implements ListInterface {
12
            private $array = [];
0 ignored issues
show
Coding Style introduced by
Private member variable "array" must contain a leading underscore
Loading history...
introduced by
The private property $array is not used, and could be removed.
Loading history...
13
            use ArrayListTrait;
14
        };
15
    }
16
17 61
    final public static function listOf(...$elements): ListInterface
18
    {
19 61
        return listFromArray($elements);
20
    }
21
22 63
    final public static function listFromArray($elements): ListInterface
23
    {
24 63
        $list = emptyList();
25 63
        $list->setArray(array_values($elements));
26 63
        return $list;
27
    }
28
29 2
    public static function isList($value): bool
30
    {
31 2
        return $value instanceof ListInterface;
32
    }
33
}
34
35
function emptyList(): ListInterface
36
{
37 73
    return Functions::emptyList();
38
}
39
40
function listOf(...$elements): ListInterface
41
{
42 61
    return Functions::listOf(...$elements);
43
}
44
45
function listFromArray(array $elements): ListInterface
46
{
47 63
    return Functions::listFromArray($elements);
48
}
49
50
function isList($value): bool
51
{
52 2
    return Functions::isList($value);
53
}
54