StdClassEncoder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 3 1
A encode() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Frostaly\VarExporter\Encoders;
6
7
use Frostaly\VarExporter\Contracts\EncoderInterface;
8
use Frostaly\VarExporter\Encoder;
9
10
class StdClassEncoder implements EncoderInterface
11
{
12
    /**
13
     * {@inheritDoc}
14
     */
15
    public function supports(mixed $value): bool
16
    {
17
        return $value instanceof \stdClass;
18
    }
19
20
    /**
21
     * {@inheritDoc}
22
     *
23
     * @param \stdClass $object
24
     */
25
    public function encode(Encoder $encoder, mixed $object): array
26
    {
27
        return [
28
            '(object) ',
29
            ...$encoder->encode((array) $object),
30
        ];
31
    }
32
}
33