Failed Conditions
Push — master ( 55bfad...b74acd )
by Maximo
02:48
created

CompaniesBranches::getSource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Gewaer\Models;
5
6
use Phalcon\Validation;
7
use Phalcon\Validation\Validator\PresenceOf;
8
9
/**
10
 * Class CompanyBranches
11
 *
12
 * @package Gewaer\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 $description;
34
35
    /**
36
     *
37
     * @var integer
38
     */
39
    public $companies_id;
40
41
    /**
42
     *
43
     * @var integer
44
     */
45
    public $users_id;
46
47
    /**
48
     *
49
     * @var integer
50
     */
51
    public $is_default;
52
53
    /**
54
     *
55
     * @var string
56
     */
57
    public $created_at;
58
59
    /**
60
     *
61
     * @var string
62
     */
63
    public $updated_at;
64
65
    /**
66
     *
67
     * @var integer
68
     */
69
    public $is_deleted;
70
71
    /**
72
     * Initialize method for model.
73
     */
74 5
    public function initialize()
75
    {
76 5
        $this->setSource('companies_branches');
77
78 5
        $this->belongsTo(
79 5
            'companies_id',
80 5
            'Gewaer\Models\Companies',
81 5
            'id',
82 5
            ['alias' => 'company']
83
        );
84
85 5
        $this->belongsTo(
86 5
            'users_id',
87 5
            'Gewaer\Models\Users',
88 5
            'id',
89 5
            ['alias' => 'id']
90
        );
91 5
    }
92
93
    /**
94
     * Model validation
95
     *
96
     * @return void
97
     */
98 3
    public function validation()
99
    {
100 3
        $validator = new Validation();
101
102 3
        $validator->add(
103 3
            'name',
104 3
            new PresenceOf([
105 3
                'model' => $this,
106
                'required' => true,
107
            ])
108
        );
109
110 3
        return $this->validate($validator);
111
    }
112
113
    /**
114
     * Returns table name mapped in the model.
115
     *
116
     * @return string
117
     */
118 5
    public function getSource() : string
119
    {
120 5
        return 'companies_branches';
121
    }
122
}
123