Completed
Push — master ( a47a63...7aba9f )
by Nikola
9s
created

InvalidConstraintStringException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A forInvalidType() 0 7 1
A forEmptyCostraintString() 0 4 1
A forConstraintString() 0 7 1
1
<?php
2
3
/**
4
 * This file is part of the Version package.
5
 *
6
 * Copyright (c) Nikola Posa <[email protected]>
7
 *
8
 * For full copyright and license information, please refer to the LICENSE file,
9
 * located at the package root folder.
10
 */
11
12
namespace Version\Exception;
13
14
use DomainException;
15
16
/**
17
 * @author Nikola Posa <[email protected]>
18
 */
19
class InvalidConstraintStringException extends DomainException implements Exception
20
{
21 1
    public static function forInvalidType($constraintString)
22
    {
23 1
        return new self(sprintf(
24 1
            'Constraint string should be of type string; %s given',
25 1
            gettype($constraintString)
26 1
        ));
27
    }
28
29 1
    public static function forEmptyCostraintString()
30
    {
31 1
        return new self('Constraint string must not be empty');
32
    }
33
34 4
    public static function forConstraintString($constraintString)
35
    {
36 4
        return new self(sprintf(
37 4
            "Constraint string: '%s' seems to be invalid and it cannot be parsed",
38
            $constraintString
39 4
        ));
40
    }
41
}
42