Failed Conditions
Push — master ( 26605a...607f8d )
by Alexander
01:54
created

Container::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 57
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1.1125

Importance

Changes 0
Metric Value
dl 0
loc 57
ccs 15
cts 29
cp 0.5172
rs 9.6818
c 0
b 0
f 0
cc 1
eloc 32
nc 1
nop 1
crap 1.1125

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * This file is part of the Code-Insight 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/code-insight
9
 */
10
11
namespace ConsoleHelpers\CodeInsight;
12
13
14
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\CheckerFactory;
15
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\ClassChecker;
16
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\ConstantChecker;
17
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\FunctionChecker;
18
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\InPortalClassChecker;
19
use ConsoleHelpers\CodeInsight\Cache\CacheFactory;
20
use ConsoleHelpers\CodeInsight\KnowledgeBase\DatabaseManager;
21
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBaseFactory;
22
use ConsoleHelpers\ConsoleKit\Config\ConfigEditor;
23
use ConsoleHelpers\DatabaseMigration\MigrationManager;
24
use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner;
25
use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner;
26
27
class Container extends \ConsoleHelpers\ConsoleKit\Container
28
{
29
30
	/**
31
	 * {@inheritdoc}
32
	 */
33 22
	public function __construct(array $values = array())
34 22
	{
35 22
		parent::__construct($values);
36
37 22
		$this['app_name'] = 'Code-Insight';
38 22
		$this['app_version'] = '@git-version@';
39
40 22
		$this['working_directory_sub_folder'] = '.code-insight';
41
42 22
		$this['config_defaults'] = array(
43 22
			'cache.provider' => '',
44
		);
45
46
		$this['project_root_folder'] = function () {
47 22
			return dirname(dirname(__DIR__));
48
		};
49
50
		$this['migration_manager'] = function ($c) {
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $c. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
51 22
			$migrations_directory = $c['project_root_folder'] . '/migrations';
52 22
			$migration_manager = new MigrationManager($migrations_directory, $c);
53 22
			$migration_manager->registerMigrationRunner(new SqlMigrationRunner());
54 22
			$migration_manager->registerMigrationRunner(new PhpMigrationRunner());
55
56 22
			return $migration_manager;
57
		};
58
59
		$this['db_manager'] = function ($c) {
60
			return new DatabaseManager($c['migration_manager']);
61
		};
62
63
		$this['knowledge_base_factory'] = function ($c) {
64
			return new KnowledgeBaseFactory($c['db_manager']);
65
		};
66
67
		$this['bc_checker_factory'] = function ($c) {
68
			$cache = $c['cache'];
69
70
			$factory = new CheckerFactory();
71
			$factory->add(new ClassChecker($cache));
72
			$factory->add(new FunctionChecker($cache));
73
			$factory->add(new ConstantChecker($cache));
74
75
			$factory->add(new InPortalClassChecker($cache));
76
77
			return $factory;
78
		};
79
80
		$this['cache'] = function ($c) {
81
			/** @var ConfigEditor $config_editor */
82
			$config_editor = $c['config_editor'];
83
			$cache_provider = $config_editor->get('cache.provider');
84
85
			$cache_factory = new CacheFactory('');
86
87
			return $cache_factory->create('chain', array('array', $cache_provider));
88
		};
89 22
	}
90
91
}
92