Completed
Push — master ( b659c5...c65770 )
by Michael
10:22
created

EventWiring::wire()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 35
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 35
ccs 0
cts 18
cp 0
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 12
nc 8
nop 1
crap 20
1
<?php
2
declare(strict_types = 1);
3
/**
4
 * Contains class EventWiring.
5
 *
6
 * PHP version 7.0+
7
 *
8
 * LICENSE:
9
 * This file is part of Yet Another Php Eve Api Library also know as Yapeal
10
 * which can be used to access the Eve Online API data and place it into a
11
 * database.
12
 * Copyright (C) 2016-2017 Michael Cummings
13
 *
14
 * This program is free software: you can redistribute it and/or modify it
15
 * under the terms of the GNU Lesser General Public License as published by the
16
 * Free Software Foundation, either version 3 of the License, or (at your
17
 * option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful, but WITHOUT
20
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
22
 * for more details.
23
 *
24
 * You should have received a copy of the GNU Lesser General Public License
25
 * along with this program. If not, see
26
 * <http://spdx.org/licenses/LGPL-3.0.html>.
27
 *
28
 * You should be able to find a copy of this license in the COPYING-LESSER.md
29
 * file. A copy of the GNU GPL should also be available in the COPYING.md file.
30
 *
31
 * @copyright 2016-2017 Michael Cummings
32
 * @license   LGPL-3.0+
33
 * @author    Michael Cummings <[email protected]>
34
 */
35
namespace Yapeal\Configuration;
36
37
use Yapeal\Container\ContainerInterface;
38
use Yapeal\Event\EveApiEventInterface;
39
use Yapeal\Event\LogEventInterface;
40
use Yapeal\Event\MediatorInterface;
41
42
/**
43
 * Class EventWiring.
44
 */
45
class EventWiring implements WiringInterface
46
{
47
    /**
48
     * @param ContainerInterface $dic
49
     *
50
     * @throws \InvalidArgumentException
51
     */
52
    public function wire(ContainerInterface $dic)
53
    {
54
        if (empty($dic['Yapeal.Event.Callable.EveApiEvent'])) {
55
            $dic['Yapeal.Event.Callable.EveApiEvent'] = $dic->factory(
56
            /**
57
             * @param ContainerInterface $dic
58
             *
59
             * @return EveApiEventInterface
60
             */
61
             function (ContainerInterface $dic): EveApiEventInterface {
62
                 return new $dic['Yapeal.Event.Factories.eveApi']();
63
             });
64
        }
65
        if (empty($dic['Yapeal.Event.Callable.LogEvent'])) {
66
            $dic['Yapeal.Event.Callable.LogEvent'] = $dic->factory(
67
            /**
68
             * @param ContainerInterface $dic
69
             *
70
             * @return LogEventInterface
71
             */
72
             function (ContainerInterface $dic): LogEventInterface {
73
                 return new $dic['Yapeal.Event.Factories.log']();
74
             });
75
        }
76
        if (empty($dic['Yapeal.Event.Callable.Mediator'])) {
77
            /**
78
             * @param ContainerInterface $dic
79
             *
80
             * @return MediatorInterface
81
             */
82
            $dic['Yapeal.Event.Callable.Mediator'] = function (ContainerInterface $dic): MediatorInterface {
83
                return new $dic['Yapeal.Event.Classes.mediator']($dic);
84
            };
85
        }
86
    }
87
}
88