ClosureEncoder::getDefaultOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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