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

GuardException   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 25
ccs 8
cts 10
cp 0.8
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A keysRequiredInMap() 0 3 1
A keysNotAllowedInList() 0 3 1
A invalidEnforceType() 0 3 1
A invalidCollectionType() 0 3 1
A immutableCannotMutate() 0 3 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