Completed
Push — rbac ( 1ec5d5...5c33ef )
by Simon
04:39
created

BanHelper::ipIsBanned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca\Helpers;
10
11
use Waca\DataObjects\Ban;
12
use Waca\Helpers\Interfaces\IBanHelper;
13
use Waca\PdoDatabase;
14
15
class BanHelper implements IBanHelper
16
{
17
    /**
18
     * @var PdoDatabase
19
     */
20
    private $database;
21
22 2
    public function __construct(PdoDatabase $database)
23
    {
24 2
        $this->database = $database;
25 2
    }
26
27
    /**
28
     * Summary of nameIsBanned
29
     *
30
     * @param string $name The name to test if is banned.
31
     *
32
     * @return Ban
33
     */
34 2
    public function nameIsBanned($name)
35
    {
36 2
        return Ban::getBanByTarget($name, "Name", $this->database);
37
    }
38
39
    /**
40
     * Summary of emailIsBanned
41
     *
42
     * @param string $email
43
     *
44
     * @return Ban
45
     */
46
    public function emailIsBanned($email)
47
    {
48
        return Ban::getBanByTarget($email, "EMail", $this->database);
49
    }
50
51
    /**
52
     * Summary of ipIsBanned
53
     *
54
     * @param string $ip
55
     *
56
     * @return Ban
57
     */
58
    public function ipIsBanned($ip)
59
    {
60
        return Ban::getBanByTarget($ip, "IP", $this->database);
61
    }
62
}
63