Completed
Pull Request — newinternal (#285)
by Simon
06:16 queued 03:05
created

BanHelper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 48
rs 10
c 0
b 0
f 0
ccs 0
cts 16
cp 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A nameIsBanned() 0 4 1
A emailIsBanned() 0 4 1
A ipIsBanned() 0 4 1
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
    public function __construct(PdoDatabase $database)
23
    {
24
        $this->database = $database;
25
    }
26
27
    /**
28
     * Summary of nameIsBanned
29
     *
30
     * @param string $name The name to test if is banned.
31
     *
32
     * @return Ban
33
     */
34
    public function nameIsBanned($name)
35
    {
36
        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