OnBeforeHLBlockAdd   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 6 6 1
A getName() 4 4 1
A getTemplate() 4 4 1
A getReplace() 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
namespace Arrilot\BitrixMigrations\Autocreate\Handlers;
4
5
use Arrilot\BitrixMigrations\Exceptions\SkipHandlerException;
6
use Bitrix\Main\Entity\Event;
7
8 View Code Duplication
class OnBeforeHLBlockAdd extends BaseHandler implements HandlerInterface
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...
9
{
10
    /**
11
     * @var Event
12
     */
13
    protected $event;
14
15
    /**
16
     * Constructor.
17
     *
18
     * @param array $params
19
     *
20
     * @throws SkipHandlerException
21
     */
22
    public function __construct($params)
23
    {
24
        $this->event = $params[0];
25
26
        $this->fields = $this->event->getParameter('fields');
27
    }
28
29
    /**
30
     * Get migration name.
31
     *
32
     * @return string
33
     */
34
    public function getName()
35
    {
36
        return 'auto_add_hlblock_'.$this->fields['TABLE_NAME'];
37
    }
38
39
    /**
40
     * Get template name.
41
     *
42
     * @return string
43
     */
44
    public function getTemplate()
45
    {
46
        return 'auto_add_hlblock';
47
    }
48
49
    /**
50
     * Get array of placeholders to replace.
51
     *
52
     * @return array
53
     */
54
    public function getReplace()
55
    {
56
        return [
57
            'fields' => var_export($this->fields, true),
58
        ];
59
    }
60
}
61