MaintenancePlayer::attributeNames()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @property string $log
4
 */
5
class MaintenancePlayer extends CModel
6
{
7
    private $_user;
8
    private $_uid;
9
    private $_log;
10
11
    public function attributeNames() {
12
        return [];
13
    }
14
    public function getLog() { return $this->_log; }
15
16
    public function setUid($player) {
17
        $res = Yii::app()->db->createCommand()
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
18
            ->select('uid, user')
19
            ->from('main')
20
            ->where('user LIKE :user', [':user'=>$player])
21
            ->queryRow();
22
        $this->_uid = (int)$res['uid'];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
23
        $this->_user = $res['user'];
24
    }
25
26
    public function reset() {
27
        $this->_log .= "user: {$this->_user}<br/>";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
28
        $this->_log .= "uid: {$this->_uid}<br/>";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
29
        if (!$this->_uid) {
30
            return false;
31
        }
32
33
        $this->_log .= 'cleaning MySQL data:<br/>';
34
35
        //get details
36
        $p = Yii::app()->db->createCommand()
37
            ->select('*')
38
            ->from('main')
39
            ->where('uid = :uid', [':uid'=>$this->_uid])
40
            ->queryRow();
41
        //get club ownership
42
        if ($p['in_club']) {
43
            $owned = Yii::app()->db->createCommand()
44
            ->select('id')
45
            ->from('club')
46
            ->where('owner = :uid', [':uid'=>$this->_uid])
47
            ->queryScalar();
48
            if ($owned) {
49
                //delete clubs forum
50
                Yii::app()->db->createCommand("DELETE FROM forum WHERE club_id={$owned}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $owned 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...
51
                $this->_log .= ' - forum posts<br/>';
52
53
                //delete club members
54
                Yii::app()->db->createCommand("UPDATE main SET in_club=0 WHERE uid IN (SELECT uid FROM club_members WHERE club_id={$owned})")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $owned 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...
55
                Yii::app()->db->createCommand("DELETE FROM club_members WHERE club_id={$owned}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $owned 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...
56
                $this->_log .= ' - clubs members<br/>';
57
58
                //delete challenges
59
                Yii::app()->db->createCommand("DELETE FROM challenge WHERE caller={$owned} OR opponent={$owned}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $owned 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...
60
                $this->_log .= ' - clubs challenges<br/>';
61
62
                //delete club
63
                Yii::app()->db->createCommand("DELETE FROM club WHERE id={$owned}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $owned 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...
64
                $this->_log .= ' - owned club<br/>';
65
            }
66
        }
67
68
        Yii::app()->db->createCommand("DELETE FROM club_members WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
69
        $this->_log .= ' - club membership<br/>';
70
71
        Yii::app()->db->createCommand("DELETE FROM duel WHERE caller={$this->_uid} OR opponent={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
72
        $this->_log .= ' - duel data<br/>';
73
74
        Yii::app()->db->createCommand("DELETE FROM log WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
75
        Yii::app()->db->createCommand("DELETE FROM log_counters WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
76
        $this->_log .= ' - logs, counters<br/>';
77
78
        Yii::app()->db->createCommand("DELETE FROM users_baits WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
79
        Yii::app()->db->createCommand("DELETE FROM users_items WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
80
        Yii::app()->db->createCommand("DELETE FROM users_parts WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
81
        $this->_log .= ' - baits, items, parts<br/>';
82
83
        Yii::app()->db->createCommand("DELETE FROM users_missions WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
84
        $this->_log .= ' - missions<br/>';
85
86
        Yii::app()->db->createCommand("DELETE FROM visited WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
87
        $this->_log .= ' - visited waters<br/>';
88
89
        Yii::app()->db->createCommand("DELETE FROM wall WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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...
90
        $this->_log .= ' - wall<br/>';
91
92
        Yii::app()->db->createCommand("DELETE FROM main WHERE uid={$this->_uid}")->execute();
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this 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
        $this->_log .= ' - main data<br/>';
94
95
96
        $this->_log .= 'cleaning REDIS data:<br/>';
97
        $redis = Yii::app()->redis->getClient();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
98
99
        $redis->del('badges:added:'.$this->_uid);
100
        $redis->del('badges:owned:'.$this->_uid);
101
        $redis->zRem('badges:leaderboard',$this->_uid);
102
        $this->_log .= ' - badges<br/>';
103
104
        $redis->zRem('board_p:201312', $this->_uid);
105
        $redis->zRem('board_p:201311', $this->_uid);
106
        $redis->zRem('board_p:201310', $this->_uid);
107
        $redis->zRem('board_p:201309', $this->_uid);
108
        $redis->zRem('board_p:201308', $this->_uid);
109
        $redis->zRem('board_p:6month', $this->_uid);
110
        $this->_log .= ' - leaderboard<br/>';
111
112
113
        $suid = (string)$this->_uid;
114
        $key = 'counter:' . $suid[0] . ':' . $suid[1] . ':' .$suid[2] . ':' . $suid;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
115
        $redis->del($key.':all');
116
        for ($i=0; $i<100; $i++) {
117
            $redis->del($key.':levels:'.$i);
118
        }
119
        $this->_log .= ' - counters<br/>';
120
121
        $redis->del('login:days:'.$this->_uid);
122
        $this->_log .= ' - login counter<br/>';
123
124
        $redis->del('debug:setitem:'.$this->_uid);
125
        $this->_log .= ' - setitem log<br/>';
126
    }
127
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
128