Passed
Push — master ( fe7dcd...466ab7 )
by Angel Fernando Quiroz
08:26
created

DictionaryPlugin   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

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