Test Failed
Pull Request — master (#12)
by Maximo
04:50 queued 01:53
created

Apps   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 79
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSource() 0 3 1
A initialize() 0 5 1
A getACLApp() 0 9 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Gewaer\Models;
5
6
class Apps extends \Baka\Auth\Models\Apps
7
{
8
    /**
9
     *
10
     * @var integer
11
     */
12
    public $id;
13
14
    /**
15
     *
16
     * @var string
17
     */
18
    public $name;
19
20
    /**
21
     *
22
     * @var string
23
     */
24
    public $description;
25
26
    /**
27
     *
28
     * @var string
29
     */
30
    public $created_at;
31
32
    /**
33
     *
34
     * @var string
35
     */
36
    public $updated_at;
37
38
    /**
39
     *
40
     * @var integer
41
     */
42
    public $is_deleted;
43
44
    /**
45
     * Ecosystem default app
46
     * @var string
47
     */
48
    const GEWAER_DEFAULT_APP_NAME = 'Default';
49
50
    /**
51
     * Initialize method for model.
52
     */
53 13
    public function initialize()
54
    {
55 13
        parent::initialize();
56
57 13
        $this->setSource('apps');
58 13
    }
59
60
    /**
61
     * You can only get 2 variations or default in DB or the api app
62
     *
63
     * @param string $name
64
     * @return Apps
65
     */
66 11
    public static function getACLApp(string $name): Apps
67
    {
68 11
        if (trim($name) == self::GEWAER_DEFAULT_APP_NAME) {
69 10
            $app = self::findFirst(0);
70
        } else {
71 1
            $app = self::findFirst(\Phalcon\DI::getDefault()->getConfig()->app->id);
72
        }
73
74 11
        return $app;
75
    }
76
77
    /**
78
     * Returns table name mapped in the model.
79
     *
80
     * @return string
81
     */
82 11
    public function getSource() : string
83
    {
84 11
        return 'apps';
85
    }
86
}
87