AddForm::add()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 13
loc 13
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace Rudolf\Modules\Galleries\One\Admin;
4
5
use Rudolf\Component\Alerts\Alert;
6
use Rudolf\Component\Alerts\AlertsCollection;
7
8 View Code Duplication
class AddForm extends FormCheck
0 ignored issues
show
Duplication introduced by
This class 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...
9
{
10
    /**
11
     * @var AddModel
12
     */
13
    protected $model;
14
15
    /**
16
     * @param AddModel $model
17
     */
18
    public function setModel(AddModel $model)
19
    {
20
        $this->model = $model;
21
    }
22
23
    /**
24
     * @return int
25
     * @throws \Exception
26
     */
27
    public function add()
28
    {
29
        $status = $this->model->add($this->dataValidated);
30
31
        if ($status) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $status of type false|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
32
            AlertsCollection::add(new Alert(
33
                'success',
34
                'Pomyślnie dodano galerię.'
35
            ));
36
        }
37
38
        return $status;
39
    }
40
}
41