Completed
Push — master ( c91a90...e32b70 )
by Chris
02:54
created

initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php declare(strict_types=1);
2
3
namespace DaveRandom\Jom;
4
5
/**
6
 * @internal
7
 */
8
function unexpected(\Exception $e): \Error
9
{
10
    return new \Error(\sprintf(
11
        'Unexpected %s thrown in %s on line %d: %s',
12
        \get_class($e), $e->getFile(), $e->getLine(), $e->getMessage()
13
    ), $e->getCode(), $e);
14
}
15
16
/**
17
 * @param mixed $value The value to describe
18
 * @return string The class name if the value is an object, otherwise the type name
19
 * @internal
20
 */
21
function describe($value): string
22
{
23
    return \is_object($value)
24
        ? \get_class($value)
25
        : \gettype($value);
26
}
27
28
/**
29
 * Invoke the private static __init() method for a class
30
 * @internal
31
 */
32
function initialize(string $class): void
33
{
34
    \Closure::bind(function($target) {
35
        $target();
36
    }, null, $class)([$class, '__init']);
37
}
38