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::extractName()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
ccs 4
cts 4
cp 1
cc 2
eloc 4
nc 2
nop 1
crap 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