PlayerComponent::checkClubChallenge()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 0
1
<?php
2
/**
3
 * @property Player $model
4
 * @property integer $uid
5
 * @property boolean $clubChallenge
6
 * @property boolean $newContest
7
 */
8
class PlayerComponent extends CApplicationComponent
9
{
10
    private $model;
11
    private $clubChallenge = false;
12
    private $newContest = false;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
13
14
    public function getModel()
15
    {
16
        return $this->model;
17
    }
18
19
    public function getUid()
20
    {
21
        return $this->model->uid;
0 ignored issues
show
Bug introduced by
The property uid cannot be accessed from this context as it is declared private in class Player.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
22
    }
23
24
    public function getClubChallenge()
25
    {
26
        return $this->clubChallenge;
27
    }
28
29
    public function getNewContest()
30
    {
31
        $lastSeen = (int)Yii::app()->redis->getClient()->get('contest:lastcheck:'.$this->model->uid);
0 ignored issues
show
Bug introduced by
The property uid cannot be accessed from this context as it is declared private in class Player.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
32
        return $this->newContest > $lastSeen;
33
    }
34
35
    public function init()
36
    {
37
        $this->model = new Player();
38
        $this->model->setAllAttributes();
39
        $this->checkClubChallenge();
40
        $this->checkNewContest();
41
    }
42
43
    public function rest()
44
    {
45
        $this->model->rest();
46
    }
47
48
    protected function checkClubChallenge()
49
    {
50
        if (!$this->model->in_club) {
0 ignored issues
show
Bug introduced by
The property in_club cannot be accessed from this context as it is declared private in class Player.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
51
            return false;
52
        }
53
54
        $lastChallenge = Yii::app()->redis->getClient()->get('reminder:challenge:'.$this->model->in_club);
0 ignored issues
show
Bug introduced by
The property in_club cannot be accessed from this context as it is declared private in class Player.

This check looks for access to properties that are not accessible from the current context.

If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.

Loading history...
55
        if ($lastChallenge >= time()) {
56
            $this->clubChallenge = true;
57
        }
58
    }
59
60
    protected function checkNewContest()
61
    {
62
        $this->newContest = (bool)Yii::app()->redis->getClient()->get('contest:active');
63
    }
64
}
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...
65