CodeGetter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPriority() 0 3 1
A getValue() 0 5 1
A getName() 0 3 1
A toType() 0 3 1
1
<?php
2
3
namespace Apie\CorePlugin\ObjectAccess\Getters;
4
5
use Apie\ObjectAccessNormalizer\Getters\GetterInterface;
6
use Symfony\Component\PropertyInfo\Type;
7
8
/**
9
 * Maps getCode of exceptions.
10
 *
11
 * @internal
12
 */
13
class CodeGetter implements GetterInterface
14
{
15
    public function getName(): string
16
    {
17
        return 'code';
18
    }
19
20
    public function getValue($object)
21
    {
22
        $code = $object->getCode();
23
        // even though exceptions should return ints, some php exceptions like DBOException throw strings.
24
        return (int) $code;
25
    }
26
27
    public function toType(): ?Type
28
    {
29
        return new Type(Type::BUILTIN_TYPE_INT);
30
    }
31
32
    public function getPriority(): int
33
    {
34
        return 0;
35
    }
36
}
37