ScalarNormalizer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A denormalize() 0 2 1
A normalize() 0 2 1
A canProcess() 0 2 2
1
<?php
2
/**
3
 * @copyright  Daniel Król <[email protected]>
4
 * @license MIT
5
 * @package Mleko\Alchemist
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
declare(strict_types=1);
11
12
namespace Mleko\Alchemist\Normalizer;
13
14
15
use Mleko\Alchemist\Normalizer;
16
use Mleko\Alchemist\Type;
17
18
class ScalarNormalizer implements Normalizer
19
{
20
    private const SUPPORTED_TYPES = ['integer', 'int', 'double', 'float', 'boolean', 'bool', 'string', 'null', 'NULL'];
21
22
    /**
23
     * @inheritdoc
24
     */
25 5
    public function normalize($value, string $format, array $context = []) {
26 5
        return $value;
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32 4
    public function denormalize($data, Type $type, string $format, array $context = []) {
33 4
        return $data;
34
    }
35
36 9
    public function canProcess(Type $type, string $format): bool {
37 9
        return \in_array($type->getName(), self::SUPPORTED_TYPES) && 0 === \count($type->getSubTypes());
38
    }
39
}
40