BindingNotAcceptedException::forBindingClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 6
nc 1
nop 3
crap 1
1
<?php
2
3
/*
4
 * This file is part of the puli/discovery package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Discovery\Api\Type;
13
14
use Exception;
15
use RuntimeException;
16
17
/**
18
 * Thrown when a binding type does not accept a binding.
19
 *
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24
class BindingNotAcceptedException extends RuntimeException
25
{
26
    /**
27
     * Creates a new exception.
28
     *
29
     * @param string         $typeName     The name of the binding type.
30
     * @param string         $bindingClass The class name of the binding.
31
     * @param Exception|null $cause        The exception that caused this
32
     *                                     exception.
33
     *
34
     * @return static The created exception.
35
     */
36 6
    public static function forBindingClass($typeName, $bindingClass, Exception $cause = null)
37
    {
38 6
        return new static(sprintf(
39 6
            'The type "%s" does accept bindings of class "%s".',
40
            $typeName,
41
            $bindingClass
42 6
        ), 0, $cause);
43
    }
44
}
45