Options   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 0
loc 79
rs 10
c 0
b 0
f 0
ccs 4
cts 6
cp 0.6667
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A name() 0 2 1
A index() 0 2 1
A sharedStorage() 0 2 1
1
<?php
2
3
/**
4
 * Options
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
12
namespace Inji\Db;
13
14
/**
15
 * Class Options
16
 * @package Inji\Db
17
 *
18
 * @property int $id
19
 * @property string $connect_name
20
 * @property string $connect_alias
21
 * @property string $driver
22
 * @property string $host
23
 * @property string $user
24
 * @property string $pass
25
 * @property string $db_name
26
 * @property string $encoding
27
 * @property string $table_prefix
28
 * @property string $port
29
 */
30
class Options extends \Inji\Model {
31
32
    /**
33
     * Model options
34
     */
35
    public static $objectName = 'Db options';
36
    public static $labels = [
37
        'id' => '#',
38
        'connect_name' => 'Название',
39
        'connect_alias' => 'Алиас',
40
        'driver' => 'Тип базы',
41
        'host' => 'Хост',
42
        'user' => 'Пользователь',
43
        'pass' => 'Пароль',
44
        'db_name' => 'Название базы',
45
        'encoding' => 'Кодировка',
46
        'table_prefix' => 'Префикс',
47
        'port' => 'порт',
48
    ];
49
    public static $cols = [
50
        'id' => ['type' => 'pk'],
51
        'connect_name' => ['type' => 'text', 'default' => 'local'],
52
        'connect_alias' => ['type' => 'text', 'default' => 'local'],
53
        'driver' => ['type' => 'select', 'source' => 'array', 'sourceArray' => ['Mysql' => 'Mysql']],
54
        'host' => ['type' => 'text', 'default' => 'localhost'],
55
        'user' => ['type' => 'text', 'default' => 'root'],
56
        'pass' => ['type' => 'text'],
57
        'db_name' => ['type' => 'text', 'default' => 'test'],
58
        'encoding' => ['type' => 'text', 'default' => 'utf8'],
59
        'table_prefix' => ['type' => 'text', 'default' => 'inji_'],
60
        'port' => ['type' => 'text', 'default' => '3306'],
61
    ];
62
    public static $dataManagers = [
63
        'setup' => [
64
            'name' => 'Настройки соединения с БД',
65
            'options' => [
66
                'access' => [
67
                    'apps' => [
68
                        'setup'
69
                    ]
70
                ]
71
            ],
72
            'cols' => [
73
                'connect_name',
74
                'connect_alias',
75
                'db_name'
76
            ],
77
            'activeForm' => 'setup',
78
        ]
79
    ];
80
    public static $forms = [
81
        'setup' => [
82
            'name' => 'Соединение с БД',
83
            'options' => [
84
                'access' => [
85
                    'apps' => [
86
                        'setup'
87
                    ]
88
                ]
89
            ],
90
            'map' => [
91
                ['connect_name', 'connect_alias', 'driver'],
92
                ['host', 'user'],
93
                ['pass', 'db_name'],
94
                ['encoding', 'table_prefix', 'port']
95
            ]
96
        ]
97
    ];
98
99
    public function name() {
100
        return $this->connect_name;
101
    }
102
103 4
    public static function index() {
104 4
        return 'id';
105
    }
106
107 3
    public static function sharedStorage() {
108 3
        return \Inji\Db\Options::connection('injiStorage')->setDbOption('share', true);
109
    }
110
111
}
112