Completed
Pull Request — master (#8)
by Nikola
04:18
created

forConstraint()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 1
nop 1
crap 2
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
use Version\Constraint\ConstraintInterface;
16
17
/**
18
 * @author Nikola Posa <[email protected]>
19
 */
20
class InvalidCompositeConstraintException extends DomainException implements Exception
21
{
22 1
    public static function forType($type)
23
    {
24 1
        return new self(sprintf('Unsupported type: %s', $type));
25
    }
26
27 1
    public static function forConstraint($constraint)
28
    {
29 1
        return new self(sprintf(
30 1
            'Constraints should be %s instances; %s given',
31 1
            ConstraintInterface::class,
32 1
            is_object($constraint) ? get_class($constraint) : gettype($constraint)
33 1
        ));
34
    }
35
}
36