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

ApplicationFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 3
Metric Value
wmc 1
c 5
b 0
f 3
lcom 0
cbo 3
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 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