Container   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 24
c 1
b 0
f 0
dl 0
loc 49
ccs 19
cts 19
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 43 1
1
<?php
2
/**
3
 * This file is part of the Console-Kit library.
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 *
7
 * @copyright Alexander Obuhovich <[email protected]>
8
 * @link      https://github.com/console-helpers/console-kit
9
 */
10
11
namespace ConsoleHelpers\ConsoleKit;
12
13
14
use ConsoleHelpers\ConsoleKit\Config\ConfigEditor;
15
use ConsoleHelpers\ConsoleKit\Helper\ContainerHelper;
16
use Symfony\Component\Console\Helper\HelperSet;
17
use Symfony\Component\Console\Input\ArgvInput;
18
use Symfony\Component\Console\Output\ConsoleOutput;
19
20
class Container extends \Pimple\Container
21
{
22
23
	/**
24
	 * {@inheritdoc}
25
	 */
26 11
	public function __construct(array $values = array())
27
	{
28 11
		parent::__construct($values);
29
30 11
		$this['app_name'] = 'UNKNOWN';
31 11
		$this['app_version'] = 'UNKNOWN';
32
33 11
		$this['config_file'] = '{base}/config.json';
34 11
		$this['config_defaults'] = array();
35 11
		$this['working_directory_sub_folder'] = '.console-kit';
36
37
		$this['working_directory'] = function ($c) {
38 1
			$working_directory = new WorkingDirectory($c['working_directory_sub_folder']);
39
40 1
			return $working_directory->get();
41
		};
42
43
		$this['config_editor'] = function ($c) {
44 1
			return new ConfigEditor(
45 1
				str_replace('{base}', $c['working_directory'], $c['config_file']),
46 1
				$c['config_defaults']
47 1
			);
48
		};
49
50
		$this['input'] = function () {
51 2
			return new ArgvInput();
52
		};
53
54
		$this['output'] = function () {
55 2
			return new ConsoleOutput();
56
		};
57
58
		$this['io'] = function ($c) {
59 1
			return new ConsoleIO($c['input'], $c['output'], $c['helper_set']);
60
		};
61
62
		// Would be replaced with actual HelperSet from extended Application class.
63
		$this['helper_set'] = function () {
64 2
			return new HelperSet();
65
		};
66
67 1
		$this['container_helper'] = function ($c) {
68 1
			return new ContainerHelper($c);
69
		};
70 11
	}
71
72
}
73