Passed
Push — master ( b220c2...54e290 )
by Alexander
14:58 queued 12:49
created

ClosureEncoder::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Yiisoft\Composer\Config\Util;
4
5
use Closure;
6
use Opis\Closure\ReflectionClosure;
7
use Riimu\Kit\PHPEncoder\Encoder\Encoder;
8
9
/**
10
 * Closure encoder for Riimu Kit-PHPEncoder.
11
 */
12
class ClosureEncoder implements Encoder
13
{
14
    public function getDefaultOptions(): array
15
    {
16
        return [];
17
    }
18
19
    public function supports($value): bool
20
    {
21
        return $value instanceof Closure;
22
    }
23
24
    public function encode($value, $depth, array $options, callable $encode)
25
    {
26
        return (new ReflectionClosure($value))->getCode();
27
    }
28
}
29