Code Duplication    Length = 45-53 lines in 2 locations

src/Autocreate/Handlers/OnBeforeIBlockAdd.php 1 location

@@ 5-49 (lines=45) @@
2
3
namespace Arrilot\BitrixMigrations\Autocreate\Handlers;
4
5
class OnBeforeIBlockAdd extends BaseHandler implements HandlerInterface
6
{
7
    /**
8
     * Constructor.
9
     *
10
     * @param array $params
11
     */
12
    public function __construct($params)
13
    {
14
        $this->fields = $params[0];
15
    }
16
17
    /**
18
     * Get migration name.
19
     *
20
     * @return string
21
     */
22
    public function getName()
23
    {
24
        return "auto_add_iblock_{$this->fields['CODE']}";
25
    }
26
27
    /**
28
     * Get template name.
29
     *
30
     * @return string
31
     */
32
    public function getTemplate()
33
    {
34
        return 'auto_add_iblock';
35
    }
36
37
    /**
38
     * Get array of placeholders to replace.
39
     *
40
     * @return array
41
     */
42
    public function getReplace()
43
    {
44
        return [
45
            'fields' => var_export($this->fields, true),
46
            'code'   => "'".$this->fields['CODE']."'",
47
        ];
48
    }
49
}
50

src/Autocreate/Handlers/OnBeforeIBlockUpdate.php 1 location

@@ 7-59 (lines=53) @@
4
5
use Arrilot\BitrixMigrations\Exceptions\SkipHandlerException;
6
7
class OnBeforeIBlockUpdate extends BaseHandler implements HandlerInterface
8
{
9
    /**
10
     * Constructor.
11
     *
12
     * @param array $params
13
     * @throws SkipHandlerException
14
     */
15
    public function __construct($params)
16
    {
17
        $this->fields = $params[0];
18
19
        // Если кода нет то миграция создастся битая.
20
        // Еще это позволяет решить проблему с тем что создается лишняя миграция для торгового каталога
21
        // когда обновляют связанный с ним инфоблок.
22
        if (!$this->fields['CODE']) {
23
            throw new SkipHandlerException();
24
        }
25
    }
26
27
    /**
28
     * Get migration name.
29
     *
30
     * @return string
31
     */
32
    public function getName()
33
    {
34
        return "auto_update_iblock_{$this->fields['CODE']}";
35
    }
36
37
    /**
38
     * Get template name.
39
     *
40
     * @return string
41
     */
42
    public function getTemplate()
43
    {
44
        return 'auto_update_iblock';
45
    }
46
47
    /**
48
     * Get array of placeholders to replace.
49
     *
50
     * @return array
51
     */
52
    public function getReplace()
53
    {
54
        return [
55
            'fields' => var_export($this->fields, true),
56
            'code'   => "'".$this->fields['CODE']."'",
57
        ];
58
    }
59
}
60