Notifier   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 36
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A newMigration() 0 11 1
A deleteNotificationFromPreviousMigration() 0 6 2
1
<?php
2
3
namespace Arrilot\BitrixMigrations\Autocreate;
4
5
use CAdminNotify;
6
7
class Notifier
8
{
9
    /**
10
     * Notification tag.
11
     *
12
     * @var string
13
     */
14
    protected $tag = 'arrilot_new_migration';
15
16
    /**
17
     * Show notification that migration has been created.
18
     *
19
     * @param $migration
20
     */
21
    public function newMigration($migration)
22
    {
23
        $notification = [
24
            'MESSAGE'      => 'Migration <strong>'.$migration.'</strong> has been created and applied.',
25
            'TAG'          => $this->tag,
26
            'MODULE_ID'    => 'main',
27
            'ENABLE_CLOSE' => 'Y',
28
        ];
29
30
        CAdminNotify::add($notification);
31
    }
32
33
    /**
34
     * Delete notification from the previous migration.
35
     */
36
    public function deleteNotificationFromPreviousMigration()
37
    {
38
        if (defined('ADMIN_SECTION')) {
39
            CAdminNotify::deleteByTag($this->tag);
40
        }
41
    }
42
}
43