Passed
Pull Request — master (#668)
by butschster
09:10 queued 01:03
created

AuthorizationStatus   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
c 2
b 0
f 0
dl 0
loc 54
ccs 15
cts 15
cp 1
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A getTopics() 0 3 1
A getResponse() 0 3 1
A hasResponse() 0 3 1
A getAttributes() 0 3 1
A isSuccessful() 0 3 1
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