Completed
Push — develop ( 3bf98d...ad187c )
by Jaap
06:26
created

__invoke()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 8
nc 2
nop 1
dl 0
loc 13
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @copyright 2010-2015 Mike van Riel<[email protected]>
9
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 * @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\DomainModel;
14
15
use phpDocumentor\Application\Configuration\ConfigurationFactory;
16
use phpDocumentor\Application\Configuration\Factory\CommandlineOptionsMiddleware;
17
use phpDocumentor\Configuration;
18
use phpDocumentor\DomainModel\MergeConfigurationWithCommandLineOptions;
19
use phpDocumentor\DomainModel\Uri;
20
21
final class MergeConfigurationWithCommandLineOptionsHandler
22
{
23
    /** @var ConfigurationFactory */
24
    private $configurationFactory;
25
26
    /** @var  CommandlineOptionsMiddleware */
27
    private $commandlineOptionsMiddleware;
28
29
    /**
30
     * MergeConfigurationWithCommandLineOptionsHandler constructor.
31
     *
32
     * @param ConfigurationFactory         $configurationFactory
33
     * @param CommandlineOptionsMiddleware $commandlineOptionsMiddleware
34
     */
35
    public function __construct(
36
        ConfigurationFactory $configurationFactory,
37
        CommandlineOptionsMiddleware $commandlineOptionsMiddleware
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $commandlineOptionsMiddleware exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
38
    ) {
39
        $this->configurationFactory         = $configurationFactory;
40
        $this->commandlineOptionsMiddleware = $commandlineOptionsMiddleware;
41
    }
42
43
    public function __invoke(MergeConfigurationWithCommandLineOptions $command)
44
    {
45
        if (isset($command->getOptions()['config'])
46
            && $command->getOptions()['config']
47
            && realpath($command->getOptions()['config'])
48
        ) {
49
            $uri = new Uri(realpath($command->getOptions()['config']));
50
            $this->configurationFactory->replaceLocation($uri);
51
        }
52
53
        $this->commandlineOptionsMiddleware->provideOptions($command->getOptions());
54
        $this->configurationFactory->clearCache();
55
    }
56
}
57