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

ClearOldDataTask   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 12
c 1
b 0
f 0
dl 0
loc 21
ccs 0
cts 16
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 19 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\ConsoleTasks;
10
11
use Exception;
12
use Waca\Tasks\ConsoleTaskBase;
13
14
class ClearOldDataTask extends ConsoleTaskBase
15
{
16
    public function execute()
17
    {
18
        $dataClearInterval = $this->getSiteConfiguration()->getDataClearInterval();
19
20
        $query = $this->getDatabase()->prepare(<<<SQL
21
UPDATE request
22
SET ip = :ip, forwardedip = null, email = :mail, useragent = ''
23
WHERE date < DATE_SUB(curdate(), INTERVAL {$dataClearInterval})
24
AND status = 'Closed';
25
SQL
26
        );
27
28
        $success = $query->execute(array(
29
            ":ip"   => $this->getSiteConfiguration()->getDataClearIp(),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal :ip 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...
30
            ":mail" => $this->getSiteConfiguration()->getDataClearEmail(),
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal :mail 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...
31
        ));
32
33
        if (!$success) {
34
            throw new Exception("Error in transaction: Could not clear data.");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Error in transaction: Could not clear data. 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...
35
        }
36
    }
0 ignored issues
show
Coding Style introduced by
Expected //end execute()
Loading history...
37
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...