Completed
Push — master ( 465cbd...e0d13e )
by Marco
06:44 queued 11s
created

ServiceEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 22
c 0
b 0
f 0
ccs 10
cts 10
cp 1
rs 9.2
cc 1
eloc 9
nc 1
nop 9
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php namespace Comodojo\Dispatcher\Events;
2
3
use \Comodojo\Foundation\Base\ConfigurationTrait;
4
use \Comodojo\Foundation\Logging\LoggerTrait;
5
use \Comodojo\Foundation\Events\EventsTrait;
6
use \Comodojo\Dispatcher\Traits\CacheTrait;
7
use \Comodojo\Dispatcher\Traits\RequestTrait;
8
use \Comodojo\Dispatcher\Traits\ResponseTrait;
9
use \Comodojo\Dispatcher\Traits\RouterTrait;
10
use \Comodojo\Dispatcher\Traits\ExtraTrait;
11
use \Comodojo\Dispatcher\Request\Model as Request;
12
use \Comodojo\Dispatcher\Router\Model as Router;
13
use \Comodojo\Dispatcher\Response\Model as Response;
14
use \Comodojo\Dispatcher\Extra\Model as Extra;
15
use \Comodojo\Foundation\Events\AbstractEvent;
16
use \Comodojo\SimpleCache\Manager as CacheManager;
17
use \Comodojo\Foundation\Events\Manager as EventsManager;
18
use \Comodojo\Foundation\Base\Configuration;
19
use \Psr\Log\LoggerInterface;
20
21
/**
22
 * @package     Comodojo Dispatcher
23
 * @author      Marco Giovinazzi <[email protected]>
24
 * @author      Marco Castiello <[email protected]>
25
 * @license     MIT
26
 *
27
 * LICENSE:
28
 *
29
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35
 * THE SOFTWARE.
36
 */
37
38
class ServiceEvent extends AbstractEvent {
39
40
    use ConfigurationTrait;
41
    use LoggerTrait;
42
    use CacheTrait;
43
    use EventsTrait;
44
    use RequestTrait;
45
    use RouterTrait;
46
    use ResponseTrait;
47
    use ExtraTrait;
48
49 1
    public function __construct(
50
        $name,
51
        Configuration $configuration,
52
        LoggerInterface $logger,
53
        CacheManager $cache,
54
        EventsManager $events,
55
        Request $request,
56
        Router $router,
57
        Response $response,
58
        Extra $extra
59
    ) {
60
61 1
        parent::__construct($name);
62
63 1
        $this->setConfiguration($configuration);
64 1
        $this->setLogger($logger);
65 1
        $this->setCache($cache);
66 1
        $this->setEvents($events);
67 1
        $this->setRequest($request);
68 1
        $this->setRouter($router);
69 1
        $this->setResponse($response);
70 1
        $this->setExtra($extra);
71
72 1
    }
73
74
}
75