Test Failed
Pull Request — master (#135)
by Rafael
06:12
created

CompaniesBranches::validation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 13
ccs 7
cts 7
cp 1
crap 1
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Canvas\Models;
5
6
use Phalcon\Validation;
7
use Phalcon\Validation\Validator\PresenceOf;
0 ignored issues
show
Bug introduced by
The type Phalcon\Validation\Validator\PresenceOf was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
/**
10
 * Class CompanyBranches
11
 *
12
 * @package Canvas\Models
13
 *
14
 */
15
class CompaniesBranches extends AbstractModel
16
{
17
    /**
18
     *
19
     * @var integer
20
     */
21
    public $id;
22
23
    /**
24
     *
25
     * @var string
26
     */
27
    public $name;
28
29
    /**
30
     *
31
     * @var string
32
     */
33
    public $address;
34
35
    /**
36
     *
37
     * @var string
38
     */
39
    public $email;
40
41
    /**
42
     *
43
     * @var string
44
     */
45
    public $zipcode;
46
47
    /**
48
     *
49
     * @var string
50
     */
51
    public $phone;
52
53
    /**
54
     *
55
     * @var integer
56
     */
57
    public $companies_id;
58
59
    /**
60
     *
61
     * @var integer
62
     */
63
    public $users_id;
64
65
    /**
66
     *
67
     * @var integer
68
     */
69
    public $is_default;
70
71
    /**
72
     *
73
     * @var string
74
     */
75
    public $created_at;
76
77
    /**
78
     *
79
     * @var string
80
     */
81
    public $updated_at;
82
83
    /**
84
     *
85
     * @var integer
86
     */
87
    public $is_deleted;
88
89
    /**
90
     * Initialize method for model.
91
     */
92 2
    public function initialize()
93
    {
94 2
        $this->setSource('companies_branches');
95
96 2
        $this->belongsTo(
97 2
            'companies_id',
98 2
            'Canvas\Models\Companies',
99 2
            'id',
100 2
            ['alias' => 'company']
101
        );
102
103 2
        $this->belongsTo(
104 2
            'users_id',
105 2
            'Canvas\Models\Users',
106 2
            'id',
107 2
            ['alias' => 'id']
108
        );
109 2
    }
110
111
    /**
112
     * Model validation
113
     *
114
     * @return void
115
     */
116 2
    public function validation()
117
    {
118 2
        $validator = new Validation();
119
120 2
        $validator->add(
121 2
            'name',
122 2
            new PresenceOf([
123 2
                'model' => $this,
124
                'required' => true,
125
            ])
126
        );
127
128 2
        return $this->validate($validator);
129
    }
130
131
    /**
132
     * Returns table name mapped in the model.
133
     *
134
     * @return string
135
     */
136 2
    public function getSource() : string
137
    {
138 2
        return 'companies_branches';
139
    }
140
}
141