GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DefaultMapper   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 65
rs 10
c 0
b 0
f 0
ccs 18
cts 18
cp 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A registerMultiple() 0 6 2
A register() 0 4 1
A extractName() 0 4 1
A getClassName() 0 8 2
1
<?php
2
3
namespace RemiSan\Serializer\Mapper;
4
5
use RemiSan\Serializer\SerializableClassMapper;
6
use RemiSan\Serializer\SerializableClassNameExtractor;
7
8
class DefaultMapper implements SerializableClassMapper
9
{
10
    /**
11
     * @var SerializableClassNameExtractor
12
     */
13
    private $nameExtractor;
14
15
    /**
16
     * @var string[]
17
     */
18
    private $mapping;
19
20
    /**
21
     * Constructor.
22
     *
23
     * @param SerializableClassNameExtractor $nameExtractor
24
     */
25 30
    public function __construct(SerializableClassNameExtractor $nameExtractor)
26
    {
27 30
        $this->nameExtractor = $nameExtractor;
28 30
        $this->mapping = [];
29 30
    }
30
31
    /**
32
     * @param string[] $classes
33
     */
34 3
    public function registerMultiple(array $classes)
35
    {
36 3
        foreach ($classes as $class) {
37 3
            $this->register($class);
38 2
        }
39 3
    }
40
41
    /**
42
     * @param string $class
43
     */
44 27
    public function register($class)
45
    {
46 27
        $this->mapping[$this->extractName($class)] = $class;
47 27
    }
48
49
    /**
50
     * @param string $class
51
     *
52
     * @return string
53
     */
54 27
    public function extractName($class)
55
    {
56 27
        return $this->nameExtractor->extractName($class);
57
    }
58
59
    /**
60
     * @param string $name
61
     *
62
     * @return string
63
     */
64 18
    public function getClassName($name)
65
    {
66 18
        if (!isset($this->mapping[$name])) {
67 3
            throw new \InvalidArgumentException(sprintf('Could not find "%s"', $name));
68
        }
69
70 15
        return $this->mapping[$name];
71
    }
72
}
73