Form   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 47
loc 47
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A _construct() 10 10 1
A getHeaderText() 4 4 1
A updateSaveButton() 8 8 1
A removeButtons() 6 6 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
declare(strict_types=1);
4
5
/**
6
 * File: Form.php
7
 *
8
 * @author Maciej Sławik <[email protected]>
9
 * @copyright Copyright (C) 2019 Lizard Media (http://lizardmedia.pl)
10
 */
11
12
namespace LizardMedia\VarnishWarmer\Block\Adminhtml\PurgeMultiple;
13
14
use Magento\Backend\Block\Widget\Form\Container;
15
use Magento\Framework\Phrase;
16
17
/**
18
 * Class Form
19
 * @package LizardMedia\VarnishWarmer\Block\PurgeMultiple\Form
20
 * @codeCoverageIgnore
21
 */
22 View Code Duplication
class Form extends Container
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in 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...
23
{
24
    /**
25
     * @return void
26
     * @SuppressWarnings(PHPMD.CamelCaseMethodName)
27
     */
28
    protected function _construct(): void
29
    {
30
        $this->_blockGroup = 'LizardMedia_VarnishWarmer';
31
        $this->_controller = 'adminhtml_purgeMultiple_form';
32
33
        parent::_construct();
34
35
        $this->updateSaveButton();
36
        $this->removeButtons();
37
    }
38
39
    /**
40
     * @return Phrase
41
     */
42
    public function getHeaderText(): Phrase
43
    {
44
        return __('Varnish: purge a group of URLs');
45
    }
46
47
    /**
48
     * @return void
49
     */
50
    private function updateSaveButton(): void
51
    {
52
        $this->buttonList->update(
53
            'save',
54
            'label',
55
            __('Run process')
56
        );
57
    }
58
59
    /**
60
     * @return void
61
     */
62
    private function removeButtons(): void
63
    {
64
        $this->buttonList->remove('delete');
65
        $this->buttonList->remove('back');
66
        $this->buttonList->remove('reset');
67
    }
68
}
69