Code Duplication    Length = 44-47 lines in 5 locations

src/module/Albums/One/Admin/DelForm.php 1 location

@@ 9-52 (lines=44) @@
6
use Rudolf\Component\Alerts\AlertsCollection;
7
use Rudolf\Component\Forms\Form;
8
9
class DelForm extends Form
10
{
11
    /**
12
     * @var DelModel
13
     */
14
    private $model;
15
16
    /**
17
     * @var int
18
     */
19
    private $id;
20
21
    /**
22
     * @param DelModel $model
23
     */
24
    public function setModel(DelModel $model)
25
    {
26
        $this->model = $model;
27
    }
28
29
    public function check()
30
    {
31
        $this->validator
32
            ->checkIsInt('id', $this->data['id'], true, [
33
                'not_int' => _('Album ID is not valid'),
34
            ]);
35
36
        $this->id = $this->data['id'];
37
    }
38
39
    /**
40
     * @return bool
41
     * @throws \Exception
42
     */
43
    public function delete()
44
    {
45
        $status = $this->model->delete($this->id);
46
47
        if ($status) {
48
            AlertsCollection::add(new Alert(
49
                'success',
50
                'Pomyślnie usunięto album.'
51
            ));
52
        }
53
54
        return $status;
55
    }

src/module/Articles/One/Admin/DelForm.php 1 location

@@ 9-52 (lines=44) @@
6
use Rudolf\Component\Alerts\AlertsCollection;
7
use Rudolf\Component\Forms\Form;
8
9
class DelForm extends Form
10
{
11
    /**
12
     * @var DelModel
13
     */
14
    protected $model;
15
16
    /**
17
     * @var int
18
     */
19
    protected $id;
20
21
    /**
22
     * @param DelModel $model
23
     */
24
    public function setModel(DelModel $model)
25
    {
26
        $this->model = $model;
27
    }
28
29
    public function check()
30
    {
31
        $this->validator
32
            ->checkIsInt('id', $this->data['id'], true, [
33
                'not_int' => _('Article ID is not valid'),
34
            ]);
35
36
        $this->id = $this->data['id'];
37
    }
38
39
    /**
40
     * @return bool
41
     * @throws \Exception
42
     */
43
    public function delete()
44
    {
45
        $status = $this->model->delete($this->id);
46
47
        if ($status) {
48
            AlertsCollection::add(new Alert(
49
                'success',
50
                'Pomyślnie usunięto artykuł.'
51
            ));
52
        }
53
54
        return $status;
55
    }

src/module/Categories/One/Admin/DelForm.php 1 location

@@ 9-55 (lines=47) @@
6
use Rudolf\Component\Alerts\AlertsCollection;
7
use Rudolf\Component\Forms\Form;
8
9
class DelForm extends Form
10
{
11
    /**
12
     * @var DelModel
13
     */
14
    protected $model;
15
16
    /**
17
     * @var int
18
     */
19
    private $id;
20
21
    /**
22
     * @param DelModel $model
23
     */
24
    public function setModel(DelModel $model)
25
    {
26
        $this->model = $model;
27
    }
28
29
    public function check()
30
    {
31
        $this->validator
32
            ->checkIsInt('id', $this->data['id'], true, [
33
                'not_int' => _('Category ID is not valid'),
34
            ]);
35
36
        $this->id = $this->data['id'];
37
    }
38
39
    /**
40
     * @return bool
41
     * @throws \Exception
42
     */
43
    public function delete()
44
    {
45
        $status = $this->model->delete($this->id);
46
47
        if ($status) {
48
            AlertsCollection::add(new Alert(
49
                'success',
50
                'Pomyślnie usunięto kategorię.'
51
            ));
52
        }
53
54
        return $status;
55
    }
56
}
57

src/module/Galleries/One/Admin/DelForm.php 1 location

@@ 9-52 (lines=44) @@
6
use Rudolf\Component\Alerts\Alert;
7
use Rudolf\Component\Alerts\AlertsCollection;
8
9
class DelForm extends Form
10
{
11
    /**
12
     * @var DelModel
13
     */
14
    protected $model;
15
16
    /**
17
     * @var int
18
     */
19
    protected $id;
20
21
    /**
22
     * @param DelModel $model
23
     */
24
    public function setModel(DelModel $model)
25
    {
26
        $this->model = $model;
27
    }
28
29
    public function check()
30
    {
31
        $this->validator
32
            ->checkIsInt('id', $this->data['id'], true, [
33
                'not_int' => _('Page ID is not valid'),
34
            ]);
35
36
        $this->id = $this->data['id'];
37
    }
38
39
    /**
40
     * @return bool
41
     * @throws \Exception
42
     */
43
    public function delete()
44
    {
45
        $status = $this->model->delete($this->id);
46
47
        if ($status) {
48
            AlertsCollection::add(new Alert(
49
                'success',
50
                'Pomyślnie usunięto galerię.'
51
            ));
52
        }
53
54
        return $status;
55
    }

src/module/Pages/One/Admin/DelForm.php 1 location

@@ 9-52 (lines=44) @@
6
use Rudolf\Component\Alerts\Alert;
7
use Rudolf\Component\Alerts\AlertsCollection;
8
9
class DelForm extends Form
10
{
11
    /**
12
     * @var DelModel
13
     */
14
    protected $model;
15
16
    /**
17
     * @var int
18
     */
19
    protected $id;
20
21
    /**
22
     * @param DelModel $model
23
     */
24
    public function setModel(DelModel $model)
25
    {
26
        $this->model = $model;
27
    }
28
29
    public function check()
30
    {
31
        $this->validator
32
            ->checkIsInt('id', $this->data['id'], true, [
33
                'not_int' => _('Page ID is not valid'),
34
            ]);
35
36
        $this->id = $this->data['id'];
37
    }
38
39
    /**
40
     * @return bool
41
     * @throws \Exception
42
     */
43
    public function delete()
44
    {
45
        $status = $this->model->delete($this->id);
46
47
        if ($status) {
48
            AlertsCollection::add(new Alert(
49
                'success',
50
                'Pomyślnie usunięto stronę.'
51
            ));
52
        }
53
54
        return $status;
55
    }