Passed
Pull Request — master (#22)
by Dmitriy
28:42 queued 13:51
created

ClosureEncoder::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 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