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.
Completed
Push — master ( 2513fe...8941ea )
by Henrik
9s
created

ClassNameRouter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A map() 0 10 2
A get() 0 10 3
1
<?php
2
3
namespace Bernard\Router;
4
5
use Bernard\Envelope;
6
use Bernard\Exception\ReceiverNotFoundException;
7
8
/**
9
 * @package Bernard
10
 */
11
class ClassNameRouter extends SimpleRouter
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function map(Envelope $envelope)
17
    {
18
        $receiver = $this->get($envelope->getClass());
19
20
        if (!is_callable($receiver)) {
21
            throw new ReceiverNotFoundException(sprintf('No receiver found for class "%s".', $envelope->getClass()));
22
        }
23
24
        return $receiver;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function get($name)
31
    {
32
        foreach ($this->receivers as $key => $receiver) {
33
            if (is_a($name, $key, true)) {
34
                return $receiver;
35
            }
36
        }
37
38
        return null;
39
    }
40
}
41