Passed
Push — main ( 8b0f26...0acacf )
by Yaroslav
03:02
created

HasTracker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A tracker() 0 7 2
A getClassAlias() 0 3 1
A trackerMeta() 0 5 1
A notificationMeta() 0 5 1
1
<?php
2
3
namespace NotificationTracker\Notification;
4
5
use NotificationTracker\NotificationTracker;
6
7
trait HasTracker
8
{
9
    protected ?Tracker $_tracker = null;
10
11 5
    public function tracker(): Tracker
12
    {
13 5
        if ($this->_tracker) {
14 3
            return $this->_tracker;
15
        }
16
17 5
        return $this->_tracker = new Tracker($this);
0 ignored issues
show
Bug introduced by
$this of type NotificationTracker\Notification\HasTracker is incompatible with the type Illuminate\Notifications\Notification expected by parameter $notification of NotificationTracker\Noti...\Tracker::__construct(). ( Ignorable by Annotation )

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

17
        return $this->_tracker = new Tracker(/** @scrutinizer ignore-type */ $this);
Loading history...
18
    }
19
20 5
    public function getClassAlias(): string
21
    {
22 5
        return NotificationTracker::getMapAlias(static::class);
23
    }
24
25 3
    public function trackerMeta(string|\Closure $key = null, mixed $value = null): static
26
    {
27 3
        $this->tracker()->trackerMeta($key, $value);
28
29 3
        return $this;
30
    }
31
32 3
    public function notificationMeta(string|\Closure $key = null, mixed $value = null): static
33
    {
34 3
        $this->tracker()->notificationMeta($key, $value);
35
36 3
        return $this;
37
    }
38
}
39