Completed
Push — master ( 7a52f7...a626be )
by vistart
05:53
created

NotificationTrait::rules()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 *  _   __ __ _____ _____ ___  ____  _____
5
 * | | / // // ___//_  _//   ||  __||_   _|
6
 * | |/ // /(__  )  / / / /| || |     | |
7
 * |___//_//____/  /_/ /_/ |_||_|     |_|
8
 * @link https://vistart.name/
9
 * @copyright Copyright (c) 2016 vistart
10
 * @license https://vistart.name/license/
11
 */
12
13
namespace vistart\Models\traits;
14
15
/**
16
 * This trait is used for building notification model.
17
 *
18
 * @version 2.0
19
 * @author vistart <[email protected]>
20
 */
21
trait NotificationTrait
22
{
23
    use NotificationRangeTrait;
24
25
    public $linkAttrbute = false;
26
27
    public function getLink()
28
    {
29
        $linkAttribute = $this->linkAttrbute;
30
        return $this->$linkAttribute;
31
    }
32
33
    public function setLink($link)
34
    {
35
        $linkAttribute = $this->linkAttrbute;
36
        return $this->$linkAttribute = $link;
37
    }
38
39
    public function getNotificationRules()
40
    {
41
        $rules = $this->getNotificationRangeRules();
42
43
        if (is_string($this->linkAttrbute)) {
44
            $rules[] = [
45
                $this->linkAttrbute, 'string',
46
            ];
47
        }
48
        return $rules;
49
    }
50
51
    public function enabledFields()
52
    {
53
        $fields = parent::enabledFields();
54
        if (is_string($this->linkAttribute)) {
0 ignored issues
show
Bug introduced by
The property linkAttribute does not seem to exist. Did you mean linkAttrbute?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
55
            $fields[] = $this->linkAttrbute;
56
        }
57
        if (is_string($this->rangeAttribute)) {
58
            $fields[] = $this->rangeAttribute;
59
        }
60
        return $fields;
61
    }
62
63
    public function rules()
64
    {
65
        return array_merge(parent::rules(), $this->getNotificationRules());
66
    }
67
}
68