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

ClosureEncoder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
eloc 4
c 0
b 0
f 0
dl 0
loc 15
ccs 0
cts 11
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultOptions() 0 3 1
A supports() 0 3 1
A encode() 0 3 1
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