Passed
Push — master ( 2a1a3c...478891 )
by Alexander
01:54
created

Container   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 38.71%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 40
dl 0
loc 74
ccs 12
cts 31
cp 0.3871
rs 10
c 3
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 68 1
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\BreakFilter;
15
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\CheckerFactory;
16
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\ClassChecker;
17
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\ConstantChecker;
18
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\FunctionChecker;
19
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Checker\InPortalClassChecker;
20
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter\HtmlReporter;
21
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter\JsonReporter;
22
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter\ReporterFactory;
23
use ConsoleHelpers\CodeInsight\BackwardsCompatibility\Reporter\TextReporter;
24
use ConsoleHelpers\CodeInsight\Cache\CacheFactory;
25
use ConsoleHelpers\CodeInsight\KnowledgeBase\DatabaseManager;
26
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBaseFactory;
27
use ConsoleHelpers\ConsoleKit\Config\ConfigEditor;
28
use ConsoleHelpers\DatabaseMigration\MigrationManager;
29
use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner;
30
use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner;
31
32
class Container extends \ConsoleHelpers\ConsoleKit\Container
33
{
34
35
	/**
36
	 * {@inheritdoc}
37
	 */
38 34
	public function __construct(array $values = array())
39
	{
40 34
		parent::__construct($values);
41
42 34
		$this['app_name'] = 'Code-Insight';
43 34
		$this['app_version'] = '@git-version@';
44
45 34
		$this['working_directory_sub_folder'] = '.code-insight';
46
47 34
		$this['config_defaults'] = array(
48
			'cache.provider' => '',
49
		);
50
51
		$this['project_root_folder'] = function () {
52 34
			return dirname(dirname(__DIR__));
53
		};
54
55
		$this['migration_manager'] = function ($c) {
56 34
			$migrations_directory = $c['project_root_folder'] . '/migrations';
57 34
			$migration_manager = new MigrationManager($migrations_directory, $c);
58 34
			$migration_manager->registerMigrationRunner(new SqlMigrationRunner());
59 34
			$migration_manager->registerMigrationRunner(new PhpMigrationRunner());
60
61 34
			return $migration_manager;
62
		};
63
64
		$this['db_manager'] = function ($c) {
65
			return new DatabaseManager($c['migration_manager'], $c['working_directory']);
66
		};
67
68
		$this['knowledge_base_factory'] = function ($c) {
69
			return new KnowledgeBaseFactory($c['db_manager']);
70
		};
71
72
		$this['bc_checker_factory'] = function ($c) {
73
			$cache = $c['cache'];
74
75
			$factory = new CheckerFactory();
76
			$factory->add(new ClassChecker($cache));
77
			$factory->add(new FunctionChecker($cache));
78
			$factory->add(new ConstantChecker($cache));
79
80
			$factory->add(new InPortalClassChecker($cache));
81
82
			return $factory;
83
		};
84
85
		$this['bc_reporter_factory'] = function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

85
		$this['bc_reporter_factory'] = function (/** @scrutinizer ignore-unused */ $c) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
86
			$factory = new ReporterFactory();
87
			$factory->add(new TextReporter());
88
			$factory->add(new HtmlReporter());
89
			$factory->add(new JsonReporter());
90
91
			return $factory;
92
		};
93
94
		$this['bc_break_filter'] = function ($c) {
0 ignored issues
show
Unused Code introduced by
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

94
		$this['bc_break_filter'] = function (/** @scrutinizer ignore-unused */ $c) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
95
			return new BreakFilter();
96
		};
97
98
		$this['cache'] = function ($c) {
99
			/** @var ConfigEditor $config_editor */
100
			$config_editor = $c['config_editor'];
101
			$cache_provider = $config_editor->get('cache.provider');
102
103
			$cache_factory = new CacheFactory('');
104
105
			return $cache_factory->create('chain', array('array', $cache_provider));
106
		};
107 34
	}
108
109
}
110