• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FastyBird / accounts-module / 12030623467

26 Nov 2024 12:29PM UTC coverage: 70.389%. Remained the same
12030623467

push

github

actions-user
Added missing package repository (#331)

2370 of 3367 relevant lines covered (70.39%)

40.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Documents/Roles/Role.php
1
<?php declare(strict_types = 1);
2

3
/**
4
 * Role.php
5
 *
6
 * @license        More in LICENSE.md
7
 * @copyright      http://www.fastybird.com
8
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
9
 * @package        FastyBird:AccountsModule!
10
 * @subpackage     Documents
11
 * @since          1.0.0
12
 *
13
 * @date           01.06.22
14
 */
15

16
namespace FastyBird\Module\Accounts\Documents\Roles;
17

18
use FastyBird\Core\Application\Documents as ApplicationDocuments;
19
use FastyBird\Core\Application\ObjectMapper as ApplicationObjectMapper;
20
use FastyBird\Core\Exchange\Documents as ExchangeDocuments;
21
use FastyBird\Library\Metadata\Types as MetadataTypes;
22
use FastyBird\Module\Accounts;
23
use FastyBird\Module\Accounts\Entities;
24
use Orisai\ObjectMapper;
25
use Ramsey\Uuid;
26

27
/**
28
 * Role document
29
 *
30
 * @package        FastyBird:AccountsModule!
31
 * @subpackage     Documents
32
 *
33
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
34
 */
35
#[ApplicationDocuments\Mapping\Document(entity: Entities\Roles\Role::class)]
36
#[ExchangeDocuments\Mapping\RoutingMap([
37
        Accounts\Constants::MESSAGE_BUS_ROLE_DOCUMENT_REPORTED_ROUTING_KEY,
38
        Accounts\Constants::MESSAGE_BUS_ROLE_DOCUMENT_CREATED_ROUTING_KEY,
39
        Accounts\Constants::MESSAGE_BUS_ROLE_DOCUMENT_UPDATED_ROUTING_KEY,
40
        Accounts\Constants::MESSAGE_BUS_ROLE_DOCUMENT_DELETED_ROUTING_KEY,
41
])]
42
final readonly class Role implements ApplicationDocuments\Document
43
{
44

45
        public function __construct(
46
                #[ApplicationObjectMapper\Rules\UuidValue()]
47
                private Uuid\UuidInterface $id,
48
                #[ObjectMapper\Rules\StringValue(notEmpty: true)]
49
                private string $name,
50
                #[ObjectMapper\Rules\AnyOf([
51
                        new ObjectMapper\Rules\StringValue(notEmpty: true),
52
                        new ObjectMapper\Rules\NullValue(castEmptyString: true),
53
                ])]
54
                private string|null $comment = null,
55
                #[ObjectMapper\Rules\BoolValue(castBoolLike: true)]
56
                private bool $anonymous = false,
57
                #[ObjectMapper\Rules\BoolValue(castBoolLike: true)]
58
                private bool $authenticated = false,
59
                #[ObjectMapper\Rules\BoolValue(castBoolLike: true)]
60
                private bool $administrator = false,
61
                #[ObjectMapper\Rules\AnyOf([
62
                        new ApplicationObjectMapper\Rules\UuidValue(),
63
                        new ObjectMapper\Rules\NullValue(castEmptyString: true),
64
                ])]
65
                private Uuid\UuidInterface|null $parent = null,
66
        )
67
        {
68
        }
×
69

70
        public function getId(): Uuid\UuidInterface
71
        {
72
                return $this->id;
×
73
        }
74

75
        public function getName(): string
76
        {
77
                return $this->name;
×
78
        }
79

80
        public function getComment(): string|null
81
        {
82
                return $this->comment;
×
83
        }
84

85
        public function isAnonymous(): bool
86
        {
87
                return $this->anonymous;
×
88
        }
89

90
        public function isAuthenticated(): bool
91
        {
92
                return $this->authenticated;
×
93
        }
94

95
        public function isAdministrator(): bool
96
        {
97
                return $this->administrator;
×
98
        }
99

100
        public function getParent(): Uuid\UuidInterface|null
101
        {
102
                return $this->parent;
×
103
        }
104

105
        public function getSource(): MetadataTypes\Sources\Source
106
        {
107
                return MetadataTypes\Sources\Module::ACCOUNTS;
×
108
        }
109

110
        public function toArray(): array
111
        {
112
                return [
×
113
                        'id' => $this->getId()->toString(),
×
114
                        'source' => $this->getSource()->value,
×
115
                        'name' => $this->getName(),
×
116
                        'comment' => $this->getComment(),
×
117
                        'anonymous' => $this->isAnonymous(),
×
118
                        'authenticated' => $this->isAuthenticated(),
×
119
                        'administrator' => $this->isAdministrator(),
×
120
                        'parent' => $this->getParent(),
×
121
                ];
×
122
        }
123

124
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc