OnBeforeGroupUpdate::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 OnBeforeGroupUpdate extends BaseHandler implements HandlerInterface
8
{
9
    /**
10
     * Bitrix group id.
11
     *
12
     * @var int
13
     */
14
    protected $id;
15
16
    /**
17
     * Constructor.
18
     *
19
     * @param array $params
20
     *
21
     * @throws StopHandlerException
22
     */
23 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...
24
    {
25
        $this->id = $params[0];
26
        $this->fields = $params[1];
27
28
        if (!$this->fields['STRING_ID']) {
29
            throw new StopHandlerException('Code is required to create a migration');
30
        }
31
    }
32
33
    /**
34
     * Get migration name.
35
     *
36
     * @return string
37
     */
38
    public function getName()
39
    {
40
        return "auto_update_group_{$this->fields['STRING_ID']}";
41
    }
42
43
    /**
44
     * Get template name.
45
     *
46
     * @return string
47
     */
48
    public function getTemplate()
49
    {
50
        return 'auto_update_group';
51
    }
52
53
    /**
54
     * Get array of placeholders to replace.
55
     *
56
     * @return array
57
     */
58
    public function getReplace()
59
    {
60
        return [
61
            'fields' => var_export($this->fields, true),
62
            'id'     => $this->id,
63
        ];
64
    }
65
}
66