Completed
Branch EDTR/master (810f49)
by
unknown
28:59 queued 20:31
created

WordPressPluginsPage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 33.93 %

Coupling/Cohesion

Components 3
Dependencies 5

Importance

Changes 0
Metric Value
dl 19
loc 56
rs 10
c 0
b 0
f 0
wmc 5
lcom 3
cbo 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A requestHandler() 0 8 1
A matchesCurrentRequest() 0 5 3
A registerDependencies() 19 20 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace EventEspresso\core\domain\entities\routing\handlers\admin;
4
5
use EE_Dependency_Map;
6
use EventEspresso\core\domain\entities\routing\handlers\Route;
7
use EventEspresso\core\domain\services\admin\PluginUpsells;
8
9
/**
10
 * Class WordPressPluginsPage
11
 * detects and executes logic for the WordPress Plugins admin page
12
 *
13
 * @package EventEspresso\core\domain\entities\routing\handlers\admin
14
 * @author  Brent Christensen
15
 * @since   $VID:$
16
 */
17
class WordPressPluginsPage extends Route
18
{
19
20
    /**
21
     * returns true if the current request matches this route
22
     *
23
     * @return bool
24
     * @since   $VID:$
25
     */
26
    public function matchesCurrentRequest()
27
    {
28
        global $pagenow;
29
        return $this->request->isAdmin() && $pagenow && $pagenow === 'plugins.php';
30
    }
31
32
33
    /**
34
     * @since $VID:$
35
     */
36 View Code Duplication
    protected function registerDependencies()
37
    {
38
        $this->dependency_map->registerDependencies(
39
            'EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager',
40
            [
41
                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
42
                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
43
                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
44
                'EventEspresso\core\domain\services\admin\ExitModal' => EE_Dependency_Map::load_from_cache,
45
            ]
46
        );
47
        $this->dependency_map->registerDependencies(
48
            'EventEspresso\core\domain\services\admin\ExitModal',
49
            ['EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache]
50
        );
51
        $this->dependency_map->registerDependencies(
52
            'EventEspresso\core\domain\services\admin\PluginUpsells',
53
            ['EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache]
54
        );
55
    }
56
57
58
    /**
59
     * implements logic required to run during request
60
     *
61
     * @return bool
62
     * @since   $VID:$
63
     */
64
    protected function requestHandler()
65
    {
66
        $this->loader->getShared('EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager');
67
        /** @var PluginUpsells $plugin_upsells */
68
        $plugin_upsells = $this->loader->getShared('EventEspresso\core\domain\services\admin\PluginUpsells');
69
        $plugin_upsells->decafUpsells();
70
        return true;
71
    }
72
}
73