CancellableTrait::isPropagationStopped()   A
last analyzed

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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jasny\Auth\Event;
6
7
/**
8
 * Trait for cancellable event
9
 */
10
trait CancellableTrait
11
{
12
    protected ?string $cancelled = null;
13
14
    /**
15
     * Cancel login.
16
     */
17 1
    public function cancel(string $reason): void
18
    {
19 1
        $this->cancelled = $reason;
20
    }
21
22
    /**
23
     * Is login cancelled?
24
     */
25 1
    public function isCancelled(): bool
26
    {
27 1
        return $this->cancelled !== null;
28
    }
29
30
    /**
31
     * Get reason why login was cancelled.
32
     */
33 1
    public function getCancellationReason(): string
34
    {
35 1
        return (string)$this->cancelled;
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41 1
    final public function isPropagationStopped(): bool
42
    {
43 1
        return $this->isCancelled();
44
    }
45
}
46