NativeEncoder::encode()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
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 NativeEncoder implements EncoderInterface
11
{
12
    /**
13
     * {@inheritDoc}
14
     */
15
    public function supports(mixed $value): bool
16
    {
17
        return in_array(gettype($value), [
18
            'boolean',
19
            'integer',
20
            'double',
21
            'string',
22
            'NULL',
23
        ]) || $value instanceof \UnitEnum;
1 ignored issue
show
Bug introduced by
The type UnitEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
    }
25
26
    /**
27
     * {@inheritDoc}
28
     */
29
    public function encode(Encoder $encoder, mixed $value): array
30
    {
31
        return [$value === null ? 'null' : var_export($value, true)];
32
    }
33
}
34