NoSuchParameterException::forParameterName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 8
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 parameter was not found.
19
 *
20
 * @since  1.0
21
 *
22
 * @author Bernhard Schussek <[email protected]>
23
 */
24 View Code Duplication
class NoSuchParameterException extends RuntimeException
25
{
26
    /**
27
     * Creates a new exception for the given parameter name.
28
     *
29
     * @param string         $parameterName The name of the parameter that was
30
     *                                      not found.
31
     * @param string         $typeName      The name of the type that the
32
     *                                      parameter was searched on.
33
     * @param Exception|null $cause         The exception that caused this
34
     *                                      exception.
35
     *
36
     * @return static The created exception.
37
     */
38 2
    public static function forParameterName($parameterName, $typeName, Exception $cause = null)
39
    {
40 2
        return new static(sprintf(
41 2
            'The parameter "%s" does not exist for type "%s".',
42
            $parameterName,
43
            $typeName
44 2
        ), 0, $cause);
45
    }
46
}
47