Test Failed
Pull Request — master (#80)
by Maximo
05:46
created

UserCompanyApps   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 88
ccs 0
cts 26
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 19 1
A getSource() 0 3 1
A getCurrentApp() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Gewaer\Models;
5
6
use Phalcon\Di;
7
8
class UserCompanyApps extends \Baka\Auth\Models\UserCompanyApps
9
{
10
    /**
11
     *
12
     * @var integer
13
     */
14
    public $companies_id;
15
16
    /**
17
     *
18
     * @var integer
19
     */
20
    public $apps_id;
21
22
    /**
23
     *
24
     * @var string
25
     */
26
    public $stripe_id;
27
28
    /**
29
     *
30
     * @var integer
31
     */
32
    public $subscriptions_id;
33
34
    /**
35
     *
36
     * @var string
37
     */
38
    public $created_at;
39
40
    /**
41
     *
42
     * @var string
43
     */
44
    public $updated_at;
45
46
    /**
47
     *
48
     * @var integer
49
     */
50
    public $is_deleted;
51
52
    /**
53
     * Initialize method for model.
54
     */
55
    public function initialize()
56
    {
57
        parent::initialize();
58
59
        $this->belongsTo(
60
            'companies_id',
61
            'Gewaer\Models\Companies',
62
            'id',
63
            ['alias' => 'company']
64
        );
65
66
        $this->belongsTo(
67
            'apps_id',
68
            'Gewaer\Models\Apps',
69
            'id',
70
            ['alias' => 'app']
71
        );
72
73
        $this->setSource('user_company_apps');
74
    }
75
76
    /**
77
     * Returns table name mapped in the model.
78
     *
79
     * @return string
80
     */
81
    public function getSource() : string
82
    {
83
        return 'user_company_apps';
84
    }
85
86
    /**
87
     * Get the current company app
88
     *
89
     * @return void
90
     */
91
    public static function getCurrentApp(): UserCompanyApps
92
    {
93
        return self::findFirst([
94
            'conditions' => 'companies_id = ?0 and apps_id = ?1',
95
            'bind' => [Di::getDefault()->getUserData()->currentCompanyId(), Di::getDefault()->getApp()->getId()]
96
        ]);
97
    }
98
}
99