Test Failed
Pull Request — master (#13)
by Maximo
03:28
created

Companies   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Test Coverage

Coverage 61.11%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 95
ccs 11
cts 18
cp 0.6111
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

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