AddonTableButtons::handle()   B
last analyzed

Complexity

Conditions 7
Paths 1

Size

Total Lines 59
Code Lines 36

Duplication

Lines 24
Ratio 40.68 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 24
loc 59
rs 7.5346
cc 7
eloc 36
nc 1
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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