OnBeforeGroupAdd::getTemplate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Arrilot\BitrixMigrations\Autocreate\Handlers;
4
5
use Arrilot\BitrixMigrations\Exceptions\StopHandlerException;
6
7
class OnBeforeGroupAdd extends BaseHandler implements HandlerInterface
8
{
9
    /**
10
     * Constructor.
11
     *
12
     * @param array $params
13
     *
14
     * @throws StopHandlerException
15
     */
16 View Code Duplication
    public function __construct($params)
0 ignored issues
show
Duplication introduced by
This method 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...
17
    {
18
        $this->fields = $params[0];
19
20
        if (!$this->fields['STRING_ID']) {
21
            throw new StopHandlerException('Code is required to create a migration');
22
        }
23
    }
24
25
    /**
26
     * Get migration name.
27
     *
28
     * @return string
29
     */
30
    public function getName()
31
    {
32
        return "auto_add_group_{$this->fields['STRING_ID']}";
33
    }
34
35
    /**
36
     * Get template name.
37
     *
38
     * @return string
39
     */
40
    public function getTemplate()
41
    {
42
        return 'auto_add_group';
43
    }
44
45
    /**
46
     * Get array of placeholders to replace.
47
     *
48
     * @return array
49
     */
50
    public function getReplace()
51
    {
52
        return [
53
            'fields' => var_export($this->fields, true),
54
        ];
55
    }
56
}
57