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

HasTracker::getClassAlias()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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