Completed
Push — master ( 7c429e...75748b )
by Michael
03:23
created

XslWiring   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A wire() 0 23 3
1
<?php
2
/**
3
 * Contains class XslWiring.
4
 *
5
 * PHP version 5.5
6
 *
7
 * LICENSE:
8
 * This file is part of Yet Another Php Eve Api Library also know as Yapeal
9
 * which can be used to access the Eve Online API data and place it into a
10
 * database.
11
 * Copyright (C) 2016 Michael Cummings
12
 *
13
 * This program is free software: you can redistribute it and/or modify it
14
 * under the terms of the GNU Lesser General Public License as published by the
15
 * Free Software Foundation, either version 3 of the License, or (at your
16
 * option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful, but WITHOUT
19
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
21
 * for more details.
22
 *
23
 * You should have received a copy of the GNU Lesser General Public License
24
 * along with this program. If not, see
25
 * <http://www.gnu.org/licenses/>.
26
 *
27
 * You should be able to find a copy of this license in the LICENSE.md file. A
28
 * copy of the GNU GPL should also be available in the GNU-GPL.md file.
29
 *
30
 * @copyright 2016 Michael Cummings
31
 * @license   LGPL-3.0+
32
 * @author    Michael Cummings <[email protected]>
33
 */
34
namespace Yapeal\Configuration;
35
36
use Yapeal\Container\ContainerInterface;
37
38
/**
39
 * Class XslWiring.
40
 */
41
class XslWiring implements WiringInterface
42
{
43
    /**
44
     * @param ContainerInterface $dic
45
     *
46
     * @return self Fluent interface.
47
     * @throws \LogicException
48
     * @throws \InvalidArgumentException
49
     */
50
    public function wire(ContainerInterface $dic)
51
    {
52
        if (empty($dic['Yapeal.Xsl.Transformer'])) {
53
            $dic['Yapeal.Xsl.Transformer'] = $dic->factory(
54
                function ($dic) {
55
                    return new $dic['Yapeal.Xsl.transform']($dic['Yapeal.Xsl.dir']);
56
                }
57
            );
58
        }
59
        if (!isset($dic['Yapeal.Event.Mediator'])) {
60
            $mess = 'Tried to call Mediator before it has been added';
61
            throw new \LogicException($mess);
62
        }
63
        /**
64
         * @var \Yapeal\Event\MediatorInterface $mediator
65
         */
66
        $mediator = $dic['Yapeal.Event.Mediator'];
67
        $mediator->addServiceSubscriberByEventList(
68
            'Yapeal.Xsl.Transformer',
69
            ['Yapeal.EveApi.transform' => ['transformEveApi', 'last']]
70
        );
71
        return $this;
72
    }
73
}
74