GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 804d88...9de2aa )
by t
02:26
created

Migration::createTable()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 4
eloc 14
c 3
b 0
f 0
nc 4
nop 3
dl 0
loc 19
rs 9.7998
1
<?php
2
/**
3
 * Class Migration
4
 *
5
 * @link https://www.icy2003.com/
6
 * @author icy2003 <[email protected]>
7
 * @copyright Copyright (c) 2017, icy2003
8
 */
9
10
namespace icy2003\php\iexts\yii2\db;
11
12
use icy2003\php\I;
13
use yii\db\Migration as M;
14
15
/**
16
 * Migration 扩展
17
 */
18
class Migration extends M
19
{
20
    use iSchemaBuilderTrait;
21
22
    /**
23
     * character 设置
24
     */
25
    const OPTION_CHARACTER = 'character';
26
    /**
27
     * collate 设置
28
     */
29
    const OPTION_COLLATE = 'collate';
30
31
    /**
32
     * engine 设置
33
     */
34
    const OPTION_ENGINE = 'engine';
35
36
    /**
37
     * comment 设置
38
     */
39
    const OPTION_COMMENT = 'comment';
40
41
    /**
42
     * 创建一个表
43
     *
44
     * @param string $table
45
     * @param array $columns
46
     * @param array $options
47
     *
48
     * @return void
49
     */
50
    public function createTable($table, $columns, $options = [])
51
    {
52
        if (false === $this->tableExists($table)) {
53
            if ('imysql' === $this->db->getDriverName()) {
54
                if (is_array($options)) {
55
                    $tableOptions = [
56
                        sprintf('CHARACTER SET %s', I::get($options, 'character', 'utf8')),
57
                        sprintf('COLLATE %s', I::get($options, 'collate', 'utf8_unicode_ci')),
58
                        sprintf('ENGINE=%s', I::get($options, 'engine', 'InnoDB')),
59
                        sprintf('COMMENT = "%s"', I::get($options, 'comment', '')),
60
                    ];
61
                    $optionString = implode(' ', $tableOptions);
62
                } else {
63
                    $optionString = $options;
64
                }
65
            } else {
66
                $optionString = $options;
67
            }
68
            return parent::createTable($table, $columns, $optionString);
69
        }
70
    }
71
72
    /**
73
     * 判断表是否存在
74
     *
75
     * 支持 yii2 的 {{}} 格式
76
     *
77
     * @param string $table
78
     *
79
     * @return boolean
80
     */
81
    public function tableExists($table)
82
    {
83
        if (preg_match('/{{%(.+)}}/', $table, $matches)) {
84
            $table = $matches[1];
85
        }
86
        return $this->db->createCommand()->tableExists($table);
87
    }
88
}
89