Failed Conditions
Push — rbac ( be68b4...52c28b )
by Michael
03:11
created

IrcNotificationHelper::unbanned()   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 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
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 Exception;
12
use Waca\DataObjects\Ban;
13
use Waca\DataObjects\Comment;
14
use Waca\DataObjects\EmailTemplate;
15
use Waca\DataObjects\Notification;
16
use Waca\DataObjects\Request;
17
use Waca\DataObjects\User;
18
use Waca\DataObjects\WelcomeTemplate;
19
use Waca\IrcColourCode;
20
use Waca\PdoDatabase;
21
use Waca\SiteConfiguration;
0 ignored issues
show
Bug introduced by
The type Waca\SiteConfiguration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
23
/**
24
 * Class IrcNotificationHelper
25
 * @package Waca\Helpers
26
 */
27
class IrcNotificationHelper
28
{
29
    /** @var PdoDatabase $notificationsDatabase */
30
    private $notificationsDatabase;
31
    /** @var PdoDatabase $primaryDatabase */
32
    private $primaryDatabase;
33
    /** @var bool $notificationsEnabled */
34
    private $notificationsEnabled;
35
    /** @var int $notificationType */
36
    private $notificationType;
37
    /** @var User $currentUser */
38
    private $currentUser;
39
    /** @var string $instanceName */
40
    private $instanceName;
41
    /** @var string */
42
    private $baseUrl;
43
    /** @var array */
44
    private $requestStates;
45
46
    /**
47
     * IrcNotificationHelper constructor.
48
     *
49
     * @param SiteConfiguration $siteConfiguration
50
     * @param PdoDatabase       $primaryDatabase
51
     * @param PdoDatabase       $notificationsDatabase
52
     */
53
    public function __construct(
54
        SiteConfiguration $siteConfiguration,
55
        PdoDatabase $primaryDatabase,
56
        PdoDatabase $notificationsDatabase = null
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$notificationsDatabase" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$notificationsDatabase"; expected 0 but found 1
Loading history...
57
    ) {
58
        $this->primaryDatabase = $primaryDatabase;
59
60
        if ($this->notificationsDatabase !== null) {
61
            $this->notificationsDatabase = $notificationsDatabase;
62
            $this->notificationsEnabled = $siteConfiguration->getIrcNotificationsEnabled();
63
        }
64
        else {
65
            $this->notificationsEnabled = false;
66
        }
67
68
        $this->notificationType = $siteConfiguration->getIrcNotificationType();
69
        $this->instanceName = $siteConfiguration->getIrcNotificationsInstance();
70
        $this->baseUrl = $siteConfiguration->getBaseUrl();
71
        $this->requestStates = $siteConfiguration->getRequestStates();
72
73
        $this->currentUser = User::getCurrent($primaryDatabase);
74
    }
0 ignored issues
show
Coding Style introduced by
Expected //end __construct()
Loading history...
75
76
    /**
77
     * Send a notification
78
     *
79
     * @param string $message The text to send
80
     */
81
    protected function send($message)
82
    {
83
        $instanceName = $this->instanceName;
84
85
        if (!$this->notificationsEnabled) {
86
            return;
87
        }
88
89
        $blacklist = array("DCC", "CCTP", "PRIVMSG");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal DCC does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal CCTP does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal PRIVMSG does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
90
        $message = str_replace($blacklist, "(IRC Blacklist)", $message); // Lets stop DCC etc
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal (IRC Blacklist) does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
91
92
        $msg = IrcColourCode::RESET . IrcColourCode::BOLD . "[$instanceName]" . IrcColourCode::RESET . ": $message";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $instanceName instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $message instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
93
94
        try {
95
            $notification = new Notification();
96
            $notification->setDatabase($this->notificationsDatabase);
97
            $notification->setType($this->notificationType);
98
            $notification->setText($msg);
99
100
            $notification->save();
101
        }
102
        catch (Exception $ex) {
103
            // OK, so we failed to send the notification - that db might be down?
104
            // This is non-critical, so silently fail.
105
106
            // Disable notifications for remainder of request.
107
            $this->notificationsEnabled = false;
108
        }
109
    }
0 ignored issues
show
Coding Style introduced by
Expected //end send()
Loading history...
110
111
    #region user management
112
113
    /**
114
     * send a new user notification
115
     *
116
     * @param User $user
117
     */
118
    public function userNew(User $user)
119
    {
120
        $this->send("New user: {$user->getUsername()}");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
121
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userNew()
Loading history...
122
123
    /**
124
     * send an approved notification
125
     *
126
     * @param User $user
127
     */
128
    public function userApproved(User $user)
129
    {
130
        $this->send("{$user->getUsername()} approved by " . $this->currentUser->getUsername());
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
131
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userApproved()
Loading history...
132
133
    /**
134
     * send a promoted notification
135
     *
136
     * @param User $user
137
     */
138
    public function userPromoted(User $user)
139
    {
140
        $this->send("{$user->getUsername()} promoted to tool admin by " . $this->currentUser->getUsername());
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
141
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userPromoted()
Loading history...
142
143
    /**
144
     * send a declined notification
145
     *
146
     * @param User   $user
147
     * @param string $reason the reason the user was declined
148
     */
149
    public function userDeclined(User $user, $reason)
150
    {
151
        $this->send("{$user->getUsername()} declined by " . $this->currentUser->getUsername() . " ($reason)");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $reason instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
152
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userDeclined()
Loading history...
153
154
    /**
155
     * send a demotion notification
156
     *
157
     * @param User   $user
158
     * @param string $reason the reason the user was demoted
159
     */
160
    public function userDemoted(User $user, $reason)
161
    {
162
        $this->send("{$user->getUsername()} demoted by " . $this->currentUser->getUsername() . " ($reason)");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $reason instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
163
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userDemoted()
Loading history...
164
165
    /**
166
     * send a suspended notification
167
     *
168
     * @param User   $user
169
     * @param string $reason The reason the user has been suspended
170
     */
171
    public function userSuspended(User $user, $reason)
172
    {
173
        $this->send("{$user->getUsername()} suspended by " . $this->currentUser->getUsername() . " ($reason)");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $reason instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
174
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userSuspended()
Loading history...
175
176
    /**
177
     * Send a preference change notification
178
     *
179
     * @param User $user
180
     */
181
    public function userPrefChange(User $user)
182
    {
183
        $this->send("{$user->getUsername()}'s preferences were changed by " . $this->currentUser->getUsername());
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
184
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userPrefChange()
Loading history...
185
186
    /**
187
     * Send a user renamed notification
188
     *
189
     * @param User   $user
190
     * @param string $old
191
     */
192
    public function userRenamed(User $user, $old)
193
    {
194
        $this->send($this->currentUser->getUsername() . " renamed $old to {$user->getUsername()}");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $old instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
195
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userRenamed()
Loading history...
196
197
    /**
198
     * @param User   $user
199
     * @param string $reason
200
     */
201
    public function userRolesEdited(User $user, $reason)
202
    {
203
        $currentUser = $this->currentUser->getUsername();
204
        $this->send("Active roles for {$user->getUsername()} changed by " . $currentUser . " ($reason)");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $user instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $reason instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
205
    }
0 ignored issues
show
Coding Style introduced by
Expected //end userRolesEdited()
Loading history...
206
207
    #endregion
208
209
    #region Site Notice
210
211
    /**
212
     * Summary of siteNoticeEdited
213
     */
214
    public function siteNoticeEdited()
215
    {
216
        $this->send("Site notice edited by " . $this->currentUser->getUsername());
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Site notice edited by does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
217
    }
0 ignored issues
show
Coding Style introduced by
Expected //end siteNoticeEdited()
Loading history...
218
    #endregion
219
220
    #region Welcome Templates
221
    /**
222
     * Summary of welcomeTemplateCreated
223
     *
224
     * @param WelcomeTemplate $template
225
     */
226
    public function welcomeTemplateCreated(WelcomeTemplate $template)
227
    {
228
        $this->send("Welcome template {$template->getId()} created by " . $this->currentUser->getUsername());
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $template instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
229
    }
0 ignored issues
show
Coding Style introduced by
Expected //end welcomeTemplateCreated()
Loading history...
230
231
    /**
232
     * Summary of welcomeTemplateDeleted
233
     *
234
     * @param int $templateid
235
     */
236
    public function welcomeTemplateDeleted($templateid)
237
    {
238
        $this->send("Welcome template {$templateid} deleted by " . $this->currentUser->getUsername());
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $templateid instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
239
    }
0 ignored issues
show
Coding Style introduced by
Expected //end welcomeTemplateDeleted()
Loading history...
240
241
    /**
242
     * Summary of welcomeTemplateEdited
243
     *
244
     * @param WelcomeTemplate $template
245
     */
246
    public function welcomeTemplateEdited(WelcomeTemplate $template)
247
    {
248
        $this->send("Welcome template {$template->getId()} edited by " . $this->currentUser->getUsername());
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $template instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
249
    }
0 ignored issues
show
Coding Style introduced by
Expected //end welcomeTemplateEdited()
Loading history...
250
251
    #endregion
252
253
    #region bans
254
    /**
255
     * Summary of banned
256
     *
257
     * @param Ban $ban
258
     */
259
    public function banned(Ban $ban)
260
    {
261
        if ($ban->getDuration() == -1) {
262
            $duration = "indefinitely";
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal indefinitely does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
263
        }
264
        else {
265
            $duration = "until " . date("F j, Y, g:i a", $ban->getDuration());
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal until does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal F j, Y, g:i a does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
266
        }
267
268
        $username = $this->currentUser->getUsername();
269
270
        $this->send("{$ban->getTarget()} banned by {$username} for '{$ban->getReason()}' {$duration}");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $ban instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $username instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $duration instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
271
    }
0 ignored issues
show
Coding Style introduced by
Expected //end banned()
Loading history...
272
273
    /**
274
     * Summary of unbanned
275
     *
276
     * @param Ban    $ban
277
     * @param string $unbanreason
278
     */
279
    public function unbanned(Ban $ban, $unbanreason)
280
    {
281
        $this->send($ban->getTarget() . " unbanned by " . $this->currentUser
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal unbanned by does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
282
                ->getUsername() . " (" . $unbanreason . ")");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal ( does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal ) does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
283
    }
0 ignored issues
show
Coding Style introduced by
Expected //end unbanned()
Loading history...
284
285
    #endregion
286
287
    #region request management
288
289
    /**
290
     * Summary of requestReceived
291
     *
292
     * @param Request $request
293
     */
294
    public function requestReceived(Request $request)
295
    {
296
        $this->send(
297
            IrcColourCode::DARK_GREY . "[["
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal [[ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
298
            . IrcColourCode::DARK_GREEN . "acc:"
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal acc: does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
299
            . IrcColourCode::ORANGE . $request->getId()
300
            . IrcColourCode::DARK_GREY . "]]"
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal ]] does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
301
            . IrcColourCode::RED . " N "
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal N does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
302
            . IrcColourCode::DARK_BLUE . $this->baseUrl . "/internal.php/viewRequest?id={$request->getId()} "
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
303
            . IrcColourCode::DARK_RED . "* "
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal * does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
304
            . IrcColourCode::DARK_GREEN . $request->getName()
305
            . IrcColourCode::DARK_RED . " * "
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal * does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
306
            . IrcColourCode::RESET
307
        );
308
    }
0 ignored issues
show
Coding Style introduced by
Expected //end requestReceived()
Loading history...
309
310
    /**
311
     * Summary of requestDeferred
312
     *
313
     * @param Request $request
314
     */
315
    public function requestDeferred(Request $request)
316
    {
317
        $availableRequestStates = $this->requestStates;
318
319
        $deferTo = $availableRequestStates[$request->getStatus()]['deferto'];
320
        $username = $this->currentUser->getUsername();
321
322
        $this->send("Request {$request->getId()} ({$request->getName()}) deferred to {$deferTo} by {$username}");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $deferTo instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $username instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
323
    }
0 ignored issues
show
Coding Style introduced by
Expected //end requestDeferred()
Loading history...
324
325
    /**
326
     *
327
     * Summary of requestDeferredWithMail
328
     *
329
     * @param Request $request
330
     */
331
    public function requestDeferredWithMail(Request $request)
332
    {
333
        $availableRequestStates = $this->requestStates;
334
335
        $deferTo = $availableRequestStates[$request->getStatus()]['deferto'];
336
        $username = $this->currentUser->getUsername();
337
        $id = $request->getId();
338
        $name = $request->getName();
339
340
        $this->send("Request {$id} ({$name}) deferred to {$deferTo} with an email by {$username}");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $name instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $deferTo instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $username instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
341
    }
0 ignored issues
show
Coding Style introduced by
Expected //end requestDeferredWithMail()
Loading history...
342
343
    /**
344
     * Summary of requestClosed
345
     *
346
     * @param Request $request
347
     * @param string  $closetype
348
     */
349
    public function requestClosed(Request $request, $closetype)
350
    {
351
        $username = $this->currentUser->getUsername();
352
353
        $this->send("Request {$request->getId()} ({$request->getName()}) closed ($closetype) by {$username}");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $closetype instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $username instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
354
    }
0 ignored issues
show
Coding Style introduced by
Expected //end requestClosed()
Loading history...
355
356
    /**
357
     * Summary of sentMail
358
     *
359
     * @param Request $request
360
     */
361
    public function sentMail(Request $request)
362
    {
363
        $this->send($this->currentUser->getUsername()
364
            . " sent an email related to Request {$request->getId()} ({$request->getName()})");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
365
    }
0 ignored issues
show
Coding Style introduced by
Expected //end sentMail()
Loading history...
366
367
    #endregion
368
369
    #region reservations
370
371
    /**
372
     * Summary of requestReserved
373
     *
374
     * @param Request $request
375
     */
376
    public function requestReserved(Request $request)
377
    {
378
        $username = $this->currentUser->getUsername();
379
380
        $this->send("Request {$request->getId()} ({$request->getName()}) reserved by {$username}");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $username instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
381
    }
0 ignored issues
show
Coding Style introduced by
Expected //end requestReserved()
Loading history...
382
383
    /**
384
     * Summary of requestReserveBroken
385
     *
386
     * @param Request $request
387
     */
388
    public function requestReserveBroken(Request $request)
389
    {
390
        $username = $this->currentUser->getUsername();
391
392
        $this->send("Reservation on request {$request->getId()} ({$request->getName()}) broken by {$username}");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $username instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
393
    }
0 ignored issues
show
Coding Style introduced by
Expected //end requestReserveBroken()
Loading history...
394
395
    /**
396
     * Summary of requestUnreserved
397
     *
398
     * @param Request $request
399
     */
400
    public function requestUnreserved(Request $request)
401
    {
402
        $this->send("Request {$request->getId()} ({$request->getName()}) is no longer being handled.");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
403
    }
0 ignored issues
show
Coding Style introduced by
Expected //end requestUnreserved()
Loading history...
404
405
    /**
406
     * Summary of requestReservationSent
407
     *
408
     * @param Request $request
409
     * @param User    $target
410
     */
411
    public function requestReservationSent(Request $request, User $target)
412
    {
413
        $username = $this->currentUser->getUsername();
414
415
        $this->send(
416
            "Reservation of request {$request->getId()} ({$request->getName()}) sent to {$target->getUsername()} by "
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $target instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
417
            . $username);
418
    }
0 ignored issues
show
Coding Style introduced by
Expected //end requestReservationSent()
Loading history...
419
420
    #endregion
421
422
    #region comments
423
424
    /**
425
     * Summary of commentCreated
426
     *
427
     * @param Comment $comment
428
     * @param Request $request
429
     */
430
    public function commentCreated(Comment $comment, Request $request)
431
    {
432
        $username = $this->currentUser->getUsername();
433
        $visibility = ($comment->getVisibility() == "admin" ? "private " : "");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal admin does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal private does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
434
435
        $this->send("{$username} posted a {$visibility}comment on request {$request->getId()} ({$request->getName()})");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $username instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $visibility instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $request instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
436
    }
0 ignored issues
show
Coding Style introduced by
Expected //end commentCreated()
Loading history...
437
438
    /**
439
     * Summary of commentEdited
440
     *
441
     * @param Comment $comment
442
     * @param Request $request
443
     */
444
    public function commentEdited(Comment $comment, Request $request)
445
    {
446
        $username = $this->currentUser->getUsername();
447
448
        $this->send(<<<TAG
449
Comment {$comment->getId()} on request {$request->getId()} ({$request->getName()}) edited by {$username}
450
TAG
451
        );
452
    }
0 ignored issues
show
Coding Style introduced by
Expected //end commentEdited()
Loading history...
453
454
    #endregion
455
456
    #region email management (close reasons)
457
458
    /**
459
     * Summary of emailCreated
460
     *
461
     * @param EmailTemplate $template
462
     */
463
    public function emailCreated(EmailTemplate $template)
464
    {
465
        $username = $this->currentUser->getUsername();
466
        $this->send("Email {$template->getId()} ({$template->getName()}) created by " . $username);
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $template instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
467
    }
0 ignored issues
show
Coding Style introduced by
Expected //end emailCreated()
Loading history...
468
469
    /**
470
     * Summary of emailEdited
471
     *
472
     * @param EmailTemplate $template
473
     */
474
    public function emailEdited(EmailTemplate $template)
475
    {
476
        $username = $this->currentUser->getUsername();
477
        $this->send("Email {$template->getId()} ({$template->getName()}) edited by " . $username);
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $template instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
478
    }
0 ignored issues
show
Coding Style introduced by
Expected //end emailEdited()
Loading history...
479
    #endregion
480
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
481