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.

EventNameExtractor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A extractName() 0 8 2
A canExtractName() 0 6 2
1
<?php
2
3
namespace RemiSan\Serializer\NameExtractor\Event;
4
5
use League\Event\EventInterface;
6
use RemiSan\Serializer\SerializableClassNameExtractor;
7
8
class EventNameExtractor implements SerializableClassNameExtractor
9
{
10
    /**
11
     * @param string $class
12
     *
13
     * @return string
14
     */
15 6
    public function extractName($class)
16
    {
17 6
        if (!$this->canExtractName($class)) {
18 3
            throw new \InvalidArgumentException();
19
        }
20
21 3
        return $class::NAME;
22
    }
23
24
    /**
25
     * @param string $class
26
     *
27
     * @return bool
28
     */
29 15
    public function canExtractName($class)
30
    {
31 15
        $reflection = new \ReflectionClass($class);
32
33 15
        return $reflection->implementsInterface(EventInterface::class) && defined($class . '::NAME');
34
    }
35
}
36