Code Duplication    Length = 14-21 lines in 6 locations

includes/DataObjects/EmailTemplate.php 2 locations

@@ 115-128 (lines=14) @@
112
     *
113
     * @return array
114
     */
115
    public static function getAllInactiveTemplates(PdoDatabase $database)
116
    {
117
        $statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE  active = 0;");
118
        $statement->execute();
119
120
        $resultObject = $statement->fetchAll(PDO::FETCH_CLASS, get_called_class());
121
122
        /** @var EmailTemplate $t */
123
        foreach ($resultObject as $t) {
124
            $t->setDatabase($database);
125
        }
126
127
        return $resultObject;
128
    }
129
130
    /**
131
     * @param string      $name
@@ 136-150 (lines=15) @@
133
     *
134
     * @return EmailTemplate|false
135
     */
136
    public static function getByName($name, PdoDatabase $database)
137
    {
138
        $statement = $database->prepare("SELECT * FROM `emailtemplate` WHERE name = :name LIMIT 1;");
139
        $statement->bindValue(":name", $name);
140
141
        $statement->execute();
142
143
        $resultObject = $statement->fetchObject(get_called_class());
144
145
        if ($resultObject != false) {
146
            $resultObject->setDatabase($database);
147
        }
148
149
        return $resultObject;
150
    }
151
152
    /**
153
     * @return EmailTemplate

includes/DataObjects/WelcomeTemplate.php 1 location

@@ 36-50 (lines=15) @@
33
     *
34
     * @return WelcomeTemplate[]
35
     */
36
    public static function getAll(PdoDatabase $database)
37
    {
38
        $statement = $database->prepare("SELECT * FROM welcometemplate WHERE deleted = 0;");
39
40
        $statement->execute();
41
42
        $result = array();
43
        /** @var WelcomeTemplate $v */
44
        foreach ($statement->fetchAll(PDO::FETCH_CLASS, self::class) as $v) {
45
            $v->setDatabase($database);
46
            $result[] = $v;
47
        }
48
49
        return $result;
50
    }
51
52
    /**
53
     * @throws Exception

includes/DataObjects/AntiSpoofCache.php 1 location

@@ 34-54 (lines=21) @@
31
     *
32
     * @return AntiSpoofCache|false
33
     */
34
    public static function getByUsername($username, PdoDatabase $database)
35
    {
36
        $statement = $database->prepare(<<<SQL
37
SELECT *
38
FROM antispoofcache
39
WHERE username = :id AND timestamp > date_sub(now(), INTERVAL 3 HOUR)
40
LIMIT 1
41
SQL
42
        );
43
        $statement->bindValue(":id", $username);
44
45
        $statement->execute();
46
47
        $resultObject = $statement->fetchObject(get_called_class());
48
49
        if ($resultObject != false) {
50
            $resultObject->setDatabase($database);
51
        }
52
53
        return $resultObject;
54
    }
55
56
    /**
57
     * @return string

includes/DataObjects/Ban.php 1 location

@@ 73-92 (lines=20) @@
70
     *
71
     * @return Ban
72
     */
73
    public static function getActiveId($id, PdoDatabase $database)
74
    {
75
        $statement = $database->prepare(<<<SQL
76
SELECT *
77
FROM ban
78
WHERE id = :id  AND (duration > UNIX_TIMESTAMP() OR duration = -1) AND active = 1;
79
SQL
80
        );
81
        $statement->bindValue(":id", $id);
82
83
        $statement->execute();
84
85
        $resultObject = $statement->fetchObject(get_called_class());
86
87
        if ($resultObject != false) {
88
            $resultObject->setDatabase($database);
89
        }
90
91
        return $resultObject;
92
    }
93
94
    /**
95
     * Get all active bans for a target and type.

includes/DataObjects/User.php 1 location

@@ 148-163 (lines=16) @@
145
     *
146
     * @return User|false
147
     */
148
    public static function getByOnWikiUsername($username, PdoDatabase $database)
149
    {
150
        $statement = $database->prepare("SELECT * FROM user WHERE onwikiname = :id LIMIT 1;");
151
        $statement->bindValue(":id", $username);
152
        $statement->execute();
153
154
        $resultObject = $statement->fetchObject(get_called_class());
155
156
        if ($resultObject != false) {
157
            $resultObject->setDatabase($database);
158
159
            return $resultObject;
160
        }
161
162
        return false;
163
    }
164
165
    #endregion
166