AddonTableButtons   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 68
Duplicated Lines 35.29 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 7
c 4
b 0
f 0
lcom 0
cbo 0
dl 24
loc 68
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B handle() 24 59 7

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 namespace Anomaly\AddonsModule\Addon\Table;
2
3
use Anomaly\Streams\Platform\Addon\Addon;
4
use Anomaly\Streams\Platform\Addon\Extension\Extension;
5
use Anomaly\Streams\Platform\Addon\Module\Module;
6
7
8
/**
9
 * Class AddonTableButtons
10
 *
11
 * @link          http://pyrocms.com/
12
 * @author        PyroCMS, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 */
15
class AddonTableButtons
16
{
17
18
    /**
19
     * Handle the command.
20
     *
21
     * @param AddonTableBuilder $builder
22
     */
23
    public function handle(AddonTableBuilder $builder)
24
    {
25
        $builder->setButtons(
26
            [
27
                'information' => [
28
                    'data-toggle' => 'modal',
29
                    'data-target' => '#modal',
30
                    'href'        => 'admin/addons/details/{entry.namespace}',
31
                ],
32
                'install'     => [
33
                    'data-toggle' => 'modal',
34
                    'data-target' => '#modal',
35
                    'href'        => 'admin/addons/options/{entry.namespace}',
36 View Code Duplication
                    'enabled'     => function (Addon $entry) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

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

Loading history...
37
38
                        if (!$entry instanceof Module && !$entry instanceof Extension) {
0 ignored issues
show
Bug introduced by
The class Anomaly\Streams\Platform\Addon\Module\Module does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
Bug introduced by
The class Anomaly\Streams\Platform\Addon\Extension\Extension does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
39
                            return false;
40
                        }
41
42
                        return !$entry->isInstalled();
43
                    },
44
                ],
45
                'migrate'   => [
46
                    'class'      => 'btn-success',
47
                    'icon'       => 'fa fa-level-up',
48
                    'text'       => 'anomaly.module.addons::button.migrate',
49
                    'href'       => 'admin/addons/migrate/{entry.namespace}',
50
                    'data-match' => function (Addon $entry) {
51
                        return $entry->getTitle();
52
                    },
53 View Code Duplication
                    'enabled'    => function (Addon $entry) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

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

Loading history...
54
55
                        if (!$entry instanceof Module && !$entry instanceof Extension) {
0 ignored issues
show
Bug introduced by
The class Anomaly\Streams\Platform\Addon\Module\Module does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
Bug introduced by
The class Anomaly\Streams\Platform\Addon\Extension\Extension does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
56
                            return false;
57
                        }
58
59
                        return $entry->isInstalled();
60
                    },
61
                ],
62
                'uninstall'   => [
63
                    'button'     => 'prompt',
64
                    'icon'       => 'times-circle',
65
                    'text'       => 'anomaly.module.addons::button.uninstall',
66
                    'href'       => 'admin/addons/uninstall/{entry.namespace}',
67
                    'data-match' => function (Addon $entry) {
68
                        return $entry->getTitle();
69
                    },
70 View Code Duplication
                    'enabled'    => function (Addon $entry) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

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

Loading history...
71
72
                        if (!$entry instanceof Module && !$entry instanceof Extension) {
0 ignored issues
show
Bug introduced by
The class Anomaly\Streams\Platform\Addon\Module\Module does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
Bug introduced by
The class Anomaly\Streams\Platform\Addon\Extension\Extension does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
73
                            return false;
74
                        }
75
76
                        return $entry->isInstalled();
77
                    },
78
                ],
79
            ]
80
        );
81
    }
82
}
83