GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Zookal_Mock_Model_Config   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 0
dl 0
loc 84
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _sortModuleDepends() 0 5 1
B removeDependencies() 0 15 6
A getDisabledModules() 0 11 3
A getDependencyLiars() 0 4 1
1
<?php
2
/**
3
 * @category    Zookal_Mock
4
 * @package     Model
5
 * @author      Cyrill Schumacher | {firstName}@{lastName}.fm | @SchumacherFM
6
 * @copyright   Copyright (c) Zookal Pty Ltd
7
 * @license     OSL - Open Software Licence 3.0 | http://opensource.org/licenses/osl-3.0.php
8
 */
9
10
/**
11
 * Only usable in index.php:
12
 * Mage::run($mageRunCode, $mageRunType, array(
13
 * 'config_model' => 'Zookal_Mock_Model_Config'
14
 * ));
15
 *
16
 * Class Zookal_Mock_Model_Config
17
 */
18
class Zookal_Mock_Model_Config extends Mage_Core_Model_Config
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
19
{
20
    /**
21
     * Key = active Module name => values inactive Module names whose dependency can be removed.
22
     * If you find more please send me a PR.
23
     * Maybe this config could also reside in a xml file.
24
     * @var array
25
     */
26
    protected $_dependencyLiars = array(
27
        'Mage_Reports'       => array('Mage_Sales', 'Mage_Customer'),
28
        'Mage_Log'           => array('Mage_Customer'),
29
        'Mage_Tax'           => array('Mage_Customer'),
30
        'Mage_Poll'          => array('Mage_Cms'),
31
        'Mage_Newsletter'    => array('Mage_Widget'),
32
        'Mage_Catalog'       => array('Mage_Cms'),
33
        'Mage_CatalogRule'   => array('Mage_Customer'),
34
        'Mage_CatalogIndex'  => array('Mage_CatalogRule'),
35
        'Mage_Checkout'      => array('Mage_CatalogInventory'),
36
        'Mage_Customer'      => array('Mage_Dataflow'),
37
        'Mage_Persistent'    => array('Mage_Adminhtml'),
38
        'Mage_Captcha'       => array('Mage_Adminhtml'),
39
        'VinaiKopp_LoginLog' => array('Mage_Adminhtml'),
40
    );
41
42
    /**
43
     * Removes the dependencies for some modules configured in $_dependencyLiars
44
     * e.g. if Mage_Log is active and Mage_Customer is disabled then remove Mage_Customer dependency
45
     *
46
     * @param array $modules
47
     *
48
     * @return array
49
     */
50
    protected function _sortModuleDepends($modules)
51
    {
52
        $modules = $this->removeDependencies($modules);
53
        return parent::_sortModuleDepends($modules);
54
    }
55
56
    /**
57
     * @param array $modules
58
     *
59
     * @return array
60
     */
61
    public function removeDependencies(array $modules)
62
    {
63
        $disabledModules = $this->getDisabledModules($modules);
64
        foreach ($modules as $moduleName => $config) {
65
            if (false === isset($this->_dependencyLiars[$moduleName]) || false === $config['active']) {
66
                continue;
67
            }
68
            foreach ($this->_dependencyLiars[$moduleName] as $inactiveModule) {
69
                if (true === isset($disabledModules[$inactiveModule])) { // check if it's really disabled
70
                    unset($modules[$moduleName]['depends'][$inactiveModule]); // remove dependency
71
                }
72
            }
73
        }
74
        return $modules;
75
    }
76
77
    /**
78
     * @param array $modules
79
     *
80
     * @return array
81
     */
82
    public function getDisabledModules(array $modules)
83
    {
84
        $_disabledModules = array();
85
        foreach ($modules as $moduleName => $node) {
86
            $isDisabled = $node['active'] !== true;
87
            if (true === $isDisabled) {
88
                $_disabledModules[$moduleName] = $moduleName;
89
            }
90
        }
91
        return $_disabledModules;
92
    }
93
94
    /**
95
     * @return array
96
     */
97
    public function getDependencyLiars()
98
    {
99
        return $this->_dependencyLiars;
100
    }
101
}
102