ServiceEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

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