Test Setup Failed
Pull Request — master (#21)
by Sergey
11:45
created

Notification::behaviors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
4
namespace tuyakhov\notifications\models;
5
6
7
use tuyakhov\notifications\behaviors\ReadableBehavior;
8
use yii\behaviors\TimestampBehavior;
9
use yii\db\ActiveRecord;
10
use yii\db\Expression;
11
12
/**
13
 * Database notification model
14
 * @property $level string
15
 * @property $subject string
16
 * @property $notifiable_type string
17
 * @property $notifiable_id int
18
 * @property $body string
19
 * @property $read_at string
20
 * @property $notifiable
21
 * @method  void markAsRead()
22
 * @method  void markAsUnread()
23
 * @method  bool read()
24
 * @method  bool unread()
25
 */
0 ignored issues
show
Documentation Bug introduced by
The doc comment $level at position 0 could not be parsed: Unknown type name '$level' at position 0 in $level.
Loading history...
26
class Notification extends ActiveRecord
27
{
28
29
    public static function tableName()
30
    {
31
        return 'notification';
32
    }
33
    
34
    /**
35
     * @inheritdoc
36
     */
37
    public function rules()
38
    {
39
        return [
40
            [['level', 'notifiable_type', 'subject', 'body'], 'string'],
41
            ['notifiable_id', 'integer'],
42
        ];
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function behaviors()
49
    {
50
        return [
51
            [
52
                'class' => TimestampBehavior::className(),
0 ignored issues
show
Deprecated Code introduced by
The function yii\base\BaseObject::className() has been deprecated: since 2.0.14. On PHP >=5.5, use `::class` instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

52
                'class' => /** @scrutinizer ignore-deprecated */ TimestampBehavior::className(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
53
                'value' => new Expression('NOW()'),
54
            ],
55
            ReadableBehavior::className()
0 ignored issues
show
Deprecated Code introduced by
The function yii\base\BaseObject::className() has been deprecated: since 2.0.14. On PHP >=5.5, use `::class` instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

55
            /** @scrutinizer ignore-deprecated */ ReadableBehavior::className()

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
56
        ];
57
    }
58
59
    public function getNotifiable()
60
    {
61
        return $this->hasOne($this->notifiable_type, ['id' => 'notifiable_id']);
0 ignored issues
show
Bug Best Practice introduced by
The property notifiable_type does not exist on tuyakhov\notifications\models\Notification. Since you implemented __get, consider adding a @property annotation.
Loading history...
Coding Style introduced by
Variable "notifiable_type" is not in valid camel caps format
Loading history...
62
    }
63
}