Passed
Push — master ( 9a3526...e85357 )
by Alexander
03:52
created

ObjectEncoder::getDefaultOptions()   A

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 2
Bugs 1 Features 0
Metric Value
eloc 1
c 2
b 1
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
namespace Yiisoft\Composer\Config\Util;
4
5
use Closure;
6
use Riimu\Kit\PHPEncoder\Encoder\Encoder;
7
8
class ObjectEncoder implements Encoder
9
{
10 11
    public function getDefaultOptions(): array
11
    {
12 11
        return [];
13
    }
14
15 11
    public function supports($value): bool
16
    {
17 11
        return is_object($value) && !$value instanceof Closure;
18
    }
19
20 1
    public function encode($value, $depth, array $options, callable $encode)
21
    {
22 1
        $serializedValue = \Opis\Closure\serialize($value);
23
24 1
        return '\Opis\Closure\unserialize(' . Helper::exportVar($serializedValue) . ')';
25
    }
26
}
27