FunctionException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 17
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
1
<?php
2
3
namespace mindplay\walkway;
4
5
use Closure;
6
use Exception;
7
use ReflectionFunction;
8
9
/**
10
 * Base-class for exception types, optionally adding some helpful diagnostic information
11
 * about a user-defined closure that caused a problem.
12
 */
13
abstract class FunctionException extends Exception
14
{
15
    /**
16
     * @param string       $message the error-message
17
     * @param Closure|null $func    an anonymous function related to the error-message
18
     */
19 1
    public function __construct($message, Closure $func = null)
20
    {
21 1
        if ($func !== null) {
22 1
            $fn = new ReflectionFunction($func);
23 1
            $source = $fn->getFileName() . '#' . $fn->getStartLine();
24 1
            $message = $message . ' at ' . $source;
25 1
        }
26
27 1
        parent::__construct($message);
28 1
    }
29
}
30