LoggerComponent::log()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
class LoggerComponent extends CApplicationComponent
3
{
4
    public function log($data)
5
    {
6
        $params = $this->getPlayerParams();
7
        foreach ($data as $k => $v) {
8
            $params[$k] = $v;
9
        }
10
        
11
        Yii::app()->db->createCommand()->insert('log', $params);
12
    }
13
14
    private function getPlayerParams()
15
    {
16
        $params = ['uid','xp_all','xp_delta','level','energy_max','energy','skill','skill_extended','strength','dollar','gold','owned_items','owned_baits'];
17
18
        $ret = [];
19
        foreach ($params as $param) {
20
            $ret[$param] = Yii::app()->player->model->$param;
21
        }
22
23
        return $ret;
24
    }
25
}
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...
26