Completed
Push — master ( c11d86...d758ed )
by Gianluca
13:50
created

CliControllerFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 3
crap 2
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace DoctrineModule\Service;
21
22
use DoctrineModule\Controller\CliController;
23
use Interop\Container\ContainerInterface;
24
use Interop\Container\Exception\ContainerException;
25
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
26
use Zend\ServiceManager\Exception\ServiceNotFoundException;
27
use Zend\ServiceManager\FactoryInterface;
28
use Zend\ServiceManager\ServiceLocatorInterface;
29
30
/**
31
 * Factory responsible of instantiating an {@see \DoctrineModule\Controller\CliController}
32
 *
33
 * @license MIT
34
 * @link    http://www.doctrine-project.org/
35
 * @author  Marco Pivetta <[email protected]>
36
 */
37
class CliControllerFactory implements FactoryInterface
0 ignored issues
show
Deprecated Code introduced by
The interface Zend\ServiceManager\FactoryInterface has been deprecated with message: Use Zend\ServiceManager\Factory\FactoryInterface instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
38
{
39
    /**
40
     * Create an object
41
     *
42
     * @param  ContainerInterface $container
43
     * @param  string             $requestedName
44
     * @param  null|array         $options
45
     *
46
     * @return object
47
     * @throws ServiceNotFoundException if unable to resolve the service.
48
     * @throws ServiceNotCreatedException if an exception is raised when creating a service.
49
     * @throws ContainerException if any other error occurs
50
     */
51
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
52
    {
53
        /* @var $application \Symfony\Component\Console\Application */
54
        $application = $container->get('doctrine.cli');
55
56
        return new CliController($application);
57
    }
58
59
    /**
60
     * {@inheritDoc}
61
     *
62
     * @return \DoctrineModule\Controller\CliController
63
     */
64
    public function createService(ServiceLocatorInterface $container)
65
    {
66
        return $this($container->getServiceLocator(), CliController::class);
67
    }
68
}
69