Completed
Push — 4.0 ( 2bab8b...b7ae43 )
by Marco
14:12
created

ServiceEvent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
A logger() 0 5 1
A request() 0 5 1
A router() 0 5 1
A response() 0 5 1
1
<?php namespace Comodojo\Dispatcher\Events;
2
3
use \Comodojo\Events\AbstractEvent;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, Comodojo\Dispatcher\Events\AbstractEvent.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
4
use \Comodojo\Dispatcher\Request\Model as Request;
5
use \Comodojo\Dispatcher\Router\Collector as Router;
6
use \Comodojo\Dispatcher\Response\Model as Response;
7
use \Monolog\Logger;
8
9
class ServiceEvent extends AbstractEvent {
10
11
    private $logger = null;
12
13
    private $request = null;
14
15
    private $router = null;
16
17
    private $response = null;
18
19
    public function __construct(
20
        $name,
21
        Logger $logger,
22
        Request $request,
23
        Router $router,
24
        Response $response
25
    ) {
26
27
        parent::__construct($name);
28
29
        $this->logger = $logger;
30
31
        $this->request = $request;
32
33
        $this->router = $router;
34
35
        $this->response = $response;
36
37
    }
38
39
    final public function logger() {
40
41
        return $this->logger;
42
43
    }
44
45
    final public function request() {
46
47
        return $this->request;
48
49
    }
50
51
    final public function router() {
52
53
        return $this->router;
54
55
    }
56
57
    final public function response() {
58
59
        return $this->response;
60
61
    }
62
63
}
64