Completed
Push — master ( b3f90f...c5536c )
by Daniel
03:02
created

ApplicationFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 5
Bugs 0 Features 3
Metric Value
c 5
b 0
f 3
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.4285
cc 1
eloc 9
nc 1
nop 3
crap 1
1
<?php
2
/**
3
 * This file is part of the Commander project.
4
 *
5
 * @author Daniel Schröder <[email protected]>
6
 */
7
8
namespace GravityMedia\Commander\Console;
9
10
use GravityMedia\Commander\Console\Command;
11
use GravityMedia\Commander\Console\Helper;
12
use Interop\Container\ContainerInterface;
13
use Interop\Container\Exception\ContainerException;
14
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
15
use Zend\ServiceManager\Exception\ServiceNotFoundException;
16
use Zend\ServiceManager\Factory\FactoryInterface;
17
18
/**
19
 * Application factory class.
20
 *
21
 * @package GravityMedia\Commander\Console
22
 */
23
class ApplicationFactory implements FactoryInterface
24
{
25
    /**
26
     * Create application object.
27
     *
28
     * @param  ContainerInterface $container
29
     * @param  string             $requestedName
30
     * @param  null|array         $options
31
     *
32
     * @return Application
33
     *
34
     * @throws ServiceNotFoundException if unable to resolve the service.
35
     * @throws ServiceNotCreatedException if an exception is raised when creating a service.
36
     * @throws ContainerException if any other error occurs.
37
     */
38 2
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
39
    {
40 2
        $application = new Application();
41 2
        $application->add($container->get(Command\JoinCommand::class));
42 2
        $application->add($container->get(Command\PurgeCommand::class));
43 2
        $application->add($container->get(Command\RunCommand::class));
44 2
        $application->add($container->get(Command\ShowCommand::class));
45
46 2
        $helperSet = $application->getHelperSet();
47 2
        $helperSet->set($container->get(Helper\ConfigLoaderHelper::class));
48
49 2
        return $application;
50
    }
51
}
52