GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EmailReminder_ReplacerClassBase   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 139
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 2
dl 0
loc 139
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getReplaceArray() 0 4 1
A replace() 0 9 2
A replaceHelpList() 0 19 4
A PasswordReminderLink() 0 6 1
A LoginLink() 0 6 1
A Days() 0 6 1
A BeforeOrAfter() 0 6 1
1
<?php
2
3
class EmailReminder_ReplacerClassBase extends Object implements EmailReminder_ReplacerClassInterface
4
{
5
    protected $replaceArray = array(
6
        '[PASSWORD_REMINDER_LINK]' => array(
7
            'Title' => 'Password reminder page',
8
            'Method' => 'PasswordReminderLink'
9
        ),
10
        '[LOGIN_LINK]' => array(
11
            'Title' => 'Login Page',
12
            'Method' => 'LoginLink'
13
        ),
14
        '[DAYS]' => array(
15
            'Title' => 'Replaces with the number of days, as set',
16
            'Method' => 'Days'
17
        ),
18
        '[BEFORE_OR_AFTER]' => array(
19
            'Title' => 'Replaces with before or after expiry date, as set',
20
            'Method' => 'BeforeOrAfter'
21
        )
22
    );
23
24
    /**
25
     *
26
     * @return array
27
     */
28
    public function getReplaceArray()
29
    {
30
        return $this->replaceArray;
31
    }
32
33
    /**
34
     *
35
     * @param EmailReminder $reminder
36
     * @param DataObject $record
37
     * @param string $str
38
     *
39
     * @return string
40
     */
41
    public function replace($reminder, $record, $str)
42
    {
43
        $newArray = array();
0 ignored issues
show
Unused Code introduced by
$newArray is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
44
        foreach ($this->replaceArray as $searchString => $moreInfoArray) {
45
            $method = $moreInfoArray['Method'];
46
            $str = $this->$method($reminder, $record, $searchString, $str);
47
        }
48
        return $str;
49
    }
50
51
52
    /**
53
     *
54
     * @param bool $asHTML
55
     *
56
     * @return array
0 ignored issues
show
Documentation introduced by
Should the return type not be string|array?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
57
     */
58
    public function replaceHelpList($asHTML = false)
59
    {
60
        $newArray = array();
61
        foreach ($this->replaceArray as $searchString => $moreInfoArray) {
62
            $newArray[$searchString] = $moreInfoArray['Title'];
63
        }
64
        if ($asHTML) {
65
            $html = '
66
            <ul class="replace-help-list">';
67
            foreach ($newArray as $searchString => $title) {
68
                $html .= '
69
                <li><strong>'.$searchString.':</strong> <span>'.$title.'</span></li>';
70
            }
71
            $html .= '
72
            </ul>';
73
            return $html;
74
        }
75
        return $newArray;
76
    }
77
78
    /**
79
     *
80
     * @param EmailReminder $reminder
81
     * @param DataObject $record
82
     * @param string $searchString
83
     * @param string $str
84
     *
85
     * @return string
86
     */
87
    protected function PasswordReminderLink($reminder, $record, $searchString, $str)
0 ignored issues
show
Unused Code introduced by
The parameter $reminder is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $record is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
88
    {
89
        $replace = Director::absoluteURL('Security/lostpassword');
90
        $str = str_replace($searchString, $replace, $str);
91
        return $str;
92
    }
93
94
    /**
95
     *
96
     * @param EmailReminder $reminder
97
     * @param DataObject $record
98
     * @param string $searchString
99
     * @param string $str
100
     *
101
     * @return string
102
     */
103
    protected function LoginLink($reminder, $record, $searchString, $str)
0 ignored issues
show
Unused Code introduced by
The parameter $reminder is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $record is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
104
    {
105
        $replace = Director::absoluteURL('Security/login');
106
        $str = str_replace($searchString, $replace, $str);
107
        return $str;
108
    }
109
110
    /**
111
     *
112
     * @param EmailReminder $reminder
113
     * @param DataObject $record
114
     * @param string $searchString
115
     * @param string $str
116
     *
117
     * @return string
118
     */
119
    protected function Days($reminder, $record, $searchString, $str)
0 ignored issues
show
Unused Code introduced by
The parameter $record is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
120
    {
121
        $replace = $reminder->Days;
122
        $str = str_replace($searchString, $replace, $str);
123
        return $str;
124
    }
125
126
    /**
127
     *
128
     * @param EmailReminder $reminder
129
     * @param DataObject $record
130
     * @param string $searchString
131
     * @param string $str
132
     *
133
     * @return string
134
     */
135
    protected function BeforeOrAfter($reminder, $record, $searchString, $str)
0 ignored issues
show
Unused Code introduced by
The parameter $record is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
136
    {
137
        $replace = $reminder->BeforeAfter;
138
        $str = str_replace($searchString, $replace, $str);
139
        return $str;
140
    }
141
}
142