Completed
Push — master ( a6bd78...0ffec3 )
by Julito
13:34
created

DictionaryPlugin::install()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 9
rs 9.6666
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
/**
5
 * Class DictionaryPlugin.
6
 */
7
class DictionaryPlugin extends Plugin
8
{
9
    /**
10
     * DictionaryPlugin constructor.
11
     */
12
    protected function __construct()
13
    {
14
        parent::__construct(
15
            '1.0',
16
            'Julio Montoya',
17
            [
18
                'enable_plugin_dictionary' => 'boolean',
19
            ]
20
        );
21
    }
22
23
    /**
24
     * @return DictionaryPlugin|null
25
     */
26
    public static function create()
27
    {
28
        static $result = null;
29
30
        return $result ? $result : $result = new self();
31
    }
32
33
    /**
34
     * Installation process.
35
     */
36
    public function install()
37
    {
38
        $sql = "CREATE TABLE IF NOT EXISTS plugin_dictionary (
39
                id INT NOT NULL AUTO_INCREMENT,
40
                term VARCHAR(255) NOT NULL,
41
                definition LONGTEXT NOT NULL,
42
                PRIMARY KEY (id));
43
        ";
44
        Database::query($sql);
45
    }
46
47
    /**
48
     * Uninstall process.
49
     */
50
    public function uninstall()
51
    {
52
        $sql = "DROP TABLE IF EXISTS plugin_dictionary";
53
        Database::query($sql);
54
    }
55
}
56