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

NotificationTrait   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 6
Bugs 0 Features 1
Metric Value
wmc 8
c 6
b 0
f 1
lcom 1
cbo 1
dl 0
loc 47
ccs 0
cts 24
cp 0
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getLink() 0 5 1
A setLink() 0 5 1
A getNotificationRules() 0 11 2
A enabledFields() 0 11 3
A rules() 0 4 1
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