Passed
Pull Request — master (#77)
by Dmitriy
13:44
created

ObjectEncoder::getDefaultOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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
    public function getDefaultOptions(): array
11
    {
12
        return [];
13
    }
14
15
    public function supports($value): bool
16
    {
17
        return is_object($value) && !$value instanceof Closure;
18
    }
19
20
    public function encode($value, $depth, array $options, callable $encode)
21
    {
22
        $serializedValue = \Opis\Closure\serialize($value);
23
24
        return '\Opis\Closure\unserialize(' . Helper::exportVar($serializedValue) . ')';
25
    }
26
}
27