HitCounterModel::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 11
ccs 3
cts 3
cp 1
crap 1
rs 9.9666
c 0
b 0
f 0
1
<?php
2
/**
3
 * HitCounterModel
4
 */
5
namespace coderius\hitCounter\models;
6
7
use Yii;
8
use yii\base\Model;
9
use coderius\hitCounter\Module;
10
11
class HitCounterModel extends Model{
12
    // const SCENARIO_CREATE = 'create';
13
    // const SCENARIO_UPDATE = 'update';
14
15
    public $counter_id;
16
    public $cookie_mark;
17
    public $js_cookei_enabled;
18
    public $js_java_enabled;
19
    public $js_timezone_offset;
20
    public $js_timezone;
21
    public $js_connection;
22
    public $js_current_url;
23
    public $js_referer_url;
24
    public $js_screen_width;
25
    public $js_screen_height;
26
    public $js_color_depth;
27
    public $js_browser_language;
28
    public $js_history_length;
29
    public $js_is_toutch_device;
30
    public $js_processor_ram;
31
    public $serv_ip;
32
    public $serv_user_agent;
33
    public $serv_referer_url;
34
    public $serv_server_name;
35
    public $serv_auth_user_id;
36
    public $serv_port;
37
    public $serv_cookies;
38
    public $serv_os;
39
    public $serv_client;
40
    public $serv_device;
41
    public $serv_brand;
42
    public $serv_model;
43
    public $serv_bot;
44
    public $serv_host_by_ip;
45
    public $serv_is_proxy_or_vpn;
46
47
    // public function init()
48
    // {
49
    //     parent::init();
50
    //     if ($this->getScenario() === self::SCENARIO_CREATE) {
51
    //         $this->setAttributes([
52
    //             'status' => $this->status === null ? CommentEnum::STATUS_ACTIVE : $this->status,
53
    //         ], false);
54
    //     }
55
    // }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60 21
    public function rules()
61
    {
62
        return [
63 21
            [['counter_id'], 'required'],
64
            [['js_cookei_enabled', 'js_java_enabled', 'js_timezone_offset', 'js_screen_width', 'js_screen_height', 'js_color_depth', 'js_history_length', 'js_is_toutch_device', 'js_processor_ram', 'serv_auth_user_id', 'serv_is_proxy_or_vpn', 'serv_port'], 'integer'],
65
            [['serv_cookies','js_current_url', 'js_referer_url','serv_referer_url','serv_user_agent'], 'string'],
66
            [['counter_id', 'js_timezone', 'js_connection', 'js_browser_language',  'serv_server_name', 'serv_os', 'serv_client', 'serv_device', 'serv_brand', 'serv_model', 'serv_bot', 'serv_host_by_ip'], 'string', 'max' => 255],
67
            [['cookie_mark'], 'string', 'max' => 32],
68
            [['serv_ip'], 'string', 'max' => 20],
69 21
            [['serv_auth_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => Module::getInstance()->userIdentityClass, 'targetAttribute' => ['serv_auth_user_id' => 'id']],
70
            [['cookie_mark', 'js_current_url', 'serv_ip', 'js_timezone_offset','js_timezone', 'js_connection','js_referer_url','js_screen_width','js_screen_height','js_color_depth','js_browser_language','js_history_length','js_processor_ram','serv_user_agent','serv_referer_url','serv_server_name','serv_auth_user_id','serv_port','serv_cookies','serv_os','serv_client','serv_device','serv_brand','serv_model','serv_bot','serv_host_by_ip'], 'default', 'value' => null],
71
        ];
72
    }
73
  
74
    // public function scenarios()
75
    // {
76
    //     $scenarios = parent::scenarios();
77
    //     $scenarios[self::SCENARIO_CREATE] = ['entity', 'entity_id', 'content', 'parentId', 'status', 'guest_name'];
78
    //     // $scenarios[self::SCENARIO_UPDATE] = ['entity', 'entity_id', 'content', 'parentId'];
79
    //     return $scenarios;
80
    // }
81
82
    
83
}
84
85