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.

CompositeNameExtractor   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addExtractor() 0 4 1
A extractName() 0 10 3
A canExtractName() 0 10 3
1
<?php
2
3
namespace RemiSan\Serializer\NameExtractor;
4
5
use RemiSan\Serializer\SerializableClassNameExtractor;
6
7
class CompositeNameExtractor implements SerializableClassNameExtractor
8
{
9
    /**
10
     * @var SerializableClassNameExtractor[]
11
     */
12
    private $extractors;
13
14
    /**
15
     * Constructor.
16
     */
17 12
    public function __construct()
18
    {
19 12
        $this->extractors = [];
20 12
    }
21
22
    /**
23
     * @param SerializableClassNameExtractor $extractor
24
     */
25 9
    public function addExtractor(SerializableClassNameExtractor $extractor)
26
    {
27 9
        $this->extractors[] = $extractor;
28 9
    }
29
30
    /**
31
     * @param string $class
32
     *
33
     * @return string
34
     */
35 6
    public function extractName($class)
36
    {
37 6
        foreach ($this->extractors as $extractor) {
38 3
            if ($extractor->canExtractName($class)) {
39 3
                return $extractor->extractName($class);
40
            }
41 2
        }
42
43 3
        throw new \InvalidArgumentException();
44
    }
45
46
    /**
47
     * @param string $class
48
     *
49
     * @return bool
50
     */
51 6
    public function canExtractName($class)
52
    {
53 6
        foreach ($this->extractors as $extractor) {
54 6
            if ($extractor->canExtractName($class)) {
55 4
                return true;
56
            }
57 2
        }
58
59 3
        return false;
60
    }
61
}
62