Passed
Pull Request — master (#64)
by Alexander
02:29
created

ClosureEncoder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 4
c 0
b 0
f 0
dl 0
loc 15
ccs 6
cts 6
cp 1
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 11
    public function getDefaultOptions(): array
15
    {
16 11
        return [];
17
    }
18
19 11
    public function supports($value): bool
20
    {
21 11
        return $value instanceof Closure;
22
    }
23
24 5
    public function encode($value, $depth, array $options, callable $encode)
25
    {
26 5
        return (new ReflectionClosure($value))->getCode();
27
    }
28
}
29