Passed
Push — master ( e81a64...572884 )
by Chema
01:28 queued 12s
created

GuardException::keysRequiredInMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace TypedArrays\Exceptions;
6
7
use Exception;
8
9
final class GuardException extends Exception
10
{
11
    public static function invalidCollectionType(string $collectionType): self
12
    {
13
        return new self("Only available options: array, map or list. Selected: $collectionType");
14
    }
15
16 2
    public static function invalidEnforceType(string $typeToEnforce): self
17
    {
18 2
        return new self("TypedArrays objects can only enforce scalars and objects. Tried to enforce: $typeToEnforce");
19
    }
20
21 14
    public static function keysNotAllowedInList(): self
22
    {
23 14
        return new self('This TypedArray object is a list and can not have keys.');
24
    }
25
26 14
    public static function keysRequiredInMap(): self
27
    {
28 14
        return new self('This TypedArray object is a map and must have keys.');
29
    }
30
31 26
    public static function immutableCannotMutate(): self
32
    {
33 26
        return new self('This TypedArray object is immutable.');
34
    }
35
}
36