Passed
Pull Request — master (#668)
by butschster
07:47
created

AuthorizationStatus::isSuccessful()   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 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Broadcasting;
6
7
use Psr\Http\Message\ResponseInterface;
8
9
final class AuthorizationStatus
10
{
11
    private bool $success;
12
    private array $topics;
13
    private array $attributes;
14
    private ?ResponseInterface $response;
15
16 8
    public function __construct(
17
        bool $success,
18
        array $topics,
19
        array $attributes = [],
20
        ?ResponseInterface $response = null
21
    ) {
22 8
        $this->success = $success;
23 8
        $this->topics = $topics;
24 8
        $this->attributes = $attributes;
25 8
        $this->response = $response;
26
    }
27
28
    /**
29
     * Check if authorization status is successful.
30
     */
31 3
    public function isSuccessful(): bool
32
    {
33 3
        return $this->success;
34
    }
35
36
    /**
37
     * Get list of authorized topics.
38
     */
39 1
    public function getTopics(): array
40
    {
41 1
        return $this->topics;
42
    }
43
44 1
    public function getAttributes(): array
45
    {
46 1
        return $this->attributes;
47
    }
48
49
    /**
50
     * Check if response is set.
51
     */
52 5
    public function hasResponse(): bool
53
    {
54 5
        return $this->response !== null;
55
    }
56
57
    /**
58
     * Get response object.
59
     */
60 3
    public function getResponse(): ?ResponseInterface
61
    {
62 3
        return $this->response;
63
    }
64
}
65