Test Failed
Pull Request — master (#18)
by Maximo
07:15
created

CompanyBranches   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 27
dl 0
loc 94
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A validation() 0 13 1
A initialize() 0 16 1
A getSource() 0 3 1
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
class CompanyBranches extends AbstractModel
10
{
11
    /**
12
     *
13
     * @var integer
14
     */
15
    public $id;
16
17
    /**
18
     *
19
     * @var string
20
     */
21
    public $name;
22
23
    /**
24
     *
25
     * @var integer
26
     */
27
    public $company_id;
28
29
    /**
30
     *
31
     * @var integer
32
     */
33
    public $users_id;
34
35
    /**
36
     *
37
     * @var string
38
     */
39
    public $created_at;
40
41
    /**
42
     *
43
     * @var string
44
     */
45
    public $updated_at;
46
47
    /**
48
     *
49
     * @var integer
50
     */
51
    public $is_deleted;
52
53
    /**
54
     * Initialize method for model.
55
     */
56 1
    public function initialize()
57
    {
58 1
        $this->setSource('company_branches');
59
60 1
        $this->belongsTo(
61 1
            'company_id',
62 1
            'Gewaer\Models\Companies',
63 1
            'id',
64 1
            ['alias' => 'company']
65
        );
66
67 1
        $this->belongsTo(
68 1
            'users_id',
69 1
            'Gewaer\Models\Users',
70 1
            'id',
71 1
            ['alias' => 'id']
72
        );
73 1
    }
74
75
    /**
76
     * Model validation
77
     *
78
     * @return void
79
     */
80 1
    public function validation()
81
    {
82 1
        $validator = new Validation();
83
84 1
        $validator->add(
85 1
            'name',
86 1
            new PresenceOf([
87 1
                'model' => $this,
88
                'required' => true,
89
            ])
90
        );
91
92 1
        return $this->validate($validator);
93
    }
94
95
    /**
96
     * Returns table name mapped in the model.
97
     *
98
     * @return string
99
     */
100 1
    public function getSource() : string
101
    {
102 1
        return 'company_branches';
103
    }
104
}
105