DatabaseCompareDry   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 11
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 65
ccs 0
cts 40
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
D compare() 0 55 11
1
<?php
2
3
namespace Etobi\CoreAPI\Service;
4
5
/**
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
use InvalidArgumentException;
18
19
/**
20
 * Class DatabaseDryCompare
21
 * 
22
 * @package Etobi\CoreAPI\Service
23
 * @author Georg Ringer <[email protected]>
24
 * @author Stefano Kowalke <[email protected]>
25
 */
26
class DatabaseCompareDry extends DatabaseComparator {
27
28
	/**
29
	 * Database compare.
30
	 *
31
	 * @param string $actions comma separated list of IDs
32
	 * @throws InvalidArgumentException
33
	 * @return array
34
	 */
35
	public function compare($actions) {
0 ignored issues
show
Complexity introduced by
This operation has 768 execution paths which exceeds the configured maximum of 200.

A high number of execution paths generally suggests many nested conditional statements and make the code less readible. This can usually be fixed by splitting the method into several smaller methods.

You can also find more information in the “Code” section of your repository.

Loading history...
36
		$errors = array();
37
		$results = array();
38
39
		$allowedActions = $this->getAllowedActions($actions);
40
41
		$expectedSchema = $this->sqlExpectedSchemaService->getExpectedDatabaseSchema();
42
		$currentSchema = $this->schemaMigrationService->getFieldDefinitions_database();
43
44
		$addCreateChange = $this->schemaMigrationService->getDatabaseExtra($expectedSchema, $currentSchema);
45
		$addCreateChange = $this->schemaMigrationService->getUpdateSuggestions($addCreateChange);
46
47
		$dropRemove = $this->schemaMigrationService->getDatabaseExtra($currentSchema, $expectedSchema);
48
		$dropRemove = $this->schemaMigrationService->getUpdateSuggestions($dropRemove, 'remove');
49
50
		if ($allowedActions[self::ACTION_UPDATE_CLEAR_TABLE] == 1) {
51
			$results['update_clear_table'] = $addCreateChange['clear_table'];
52
		}
53
54
		if ($allowedActions[self::ACTION_UPDATE_ADD] == 1) {
55
			$results['update_add'] = $addCreateChange['add'];
56
		}
57
58
		if ($allowedActions[self::ACTION_UPDATE_CHANGE] == 1) {
59
			$results['update_change'] = $addCreateChange['change'];
60
		}
61
62
		if ($allowedActions[self::ACTION_UPDATE_CREATE_TABLE] == 1) {
63
			$results['update_create_table'] = $addCreateChange['create_table'];
64
		}
65
66
		if ($allowedActions[self::ACTION_REMOVE_CHANGE] == 1) {
67
			$results['remove_change'] = $dropRemove['change'];
68
		}
69
70
		if ($allowedActions[self::ACTION_REMOVE_DROP] == 1) {
71
			$results['remove_drop'] = $dropRemove['drop'];
72
		}
73
74
		if ($allowedActions[self::ACTION_REMOVE_CHANGE_TABLE] == 1) {
75
			$results['remove_change_table'] = $dropRemove['change_table'];
76
		}
77
78
		if ($allowedActions[self::ACTION_REMOVE_DROP_TABLE] == 1) {
79
			$results['remove_drop_table'] = $dropRemove['drop_table'];
80
		}
81
82
		foreach ($results as $key => $resultSet) {
83
			if (!empty($resultSet)) {
84
				$errors[$key] = $resultSet;
85
			}
86
		}
87
88
		return $errors;
89
	}
90
}
91
92