ObjectEncoder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 4
eloc 5
c 2
b 1
f 0
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultOptions() 0 3 1
A encode() 0 5 1
A supports() 0 3 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config\Util;
6
7
use Closure;
8
use Riimu\Kit\PHPEncoder\Encoder\Encoder;
9
10
class ObjectEncoder implements Encoder
11
{
12 24
    public function getDefaultOptions(): array
13
    {
14 24
        return [];
15
    }
16
17 24
    public function supports($value): bool
18
    {
19 24
        return is_object($value) && !$value instanceof Closure;
20
    }
21
22 2
    public function encode($value, $depth, array $options, callable $encode)
23
    {
24 2
        $serializedValue = \Opis\Closure\serialize($value);
25
26 2
        return '\Opis\Closure\unserialize(' . Helper::exportVar($serializedValue) . ')';
27
    }
28
}
29