-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathMagazineResponseDto.php
More file actions
140 lines (133 loc) · 5.44 KB
/
Copy pathMagazineResponseDto.php
File metadata and controls
140 lines (133 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
declare(strict_types=1);
namespace App\DTO;
use App\Enums\ENotificationStatus;
use Nelmio\ApiDocBundle\Attribute\Model;
use OpenApi\Attributes as OA;
#[OA\Schema()]
class MagazineResponseDto implements \JsonSerializable
{
public ?ModeratorResponseDto $owner = null;
public ?ImageDto $icon = null;
public ?ImageDto $banner = null;
public ?string $name = null;
public ?string $title = null;
public ?string $description = null;
public ?string $rules = null;
public int $subscriptionsCount = 0;
public int $entryCount = 0;
public int $entryCommentCount = 0;
public int $postCount = 0;
public int $postCommentCount = 0;
public bool $isAdult = false;
public ?bool $isUserSubscribed = null;
public ?bool $isBlockedByUser = null;
#[OA\Property(type: 'array', description: 'Magazine tags', items: new OA\Items(type: 'string'))]
public ?array $tags = null;
#[OA\Property(type: 'array', description: 'Magazine badges', items: new OA\Items(ref: new Model(type: BadgeResponseDto::class)))]
public ?array $badges = null;
#[OA\Property(type: 'array', description: 'Moderator list', items: new OA\Items(ref: new Model(type: ModeratorResponseDto::class)))]
public ?array $moderators = null;
public ?string $apId = null;
public ?string $apProfileId = null;
public ?int $magazineId = null;
public ?string $serverSoftware = null;
public ?string $serverSoftwareVersion = null;
public bool $isPostingRestrictedToMods = false;
public ?int $localSubscribers = null;
public ?ENotificationStatus $notificationStatus = null;
public ?bool $discoverable = null;
public ?bool $indexable = null;
public static function create(
?ModeratorResponseDto $owner = null,
?ImageDto $icon = null,
?ImageDto $banner = null,
?string $name = null,
?string $title = null,
?string $description = null,
?string $rules = null,
int $subscriptionsCount = 0,
int $entryCount = 0,
int $entryCommentCount = 0,
int $postCount = 0,
int $postCommentCount = 0,
bool $isAdult = false,
?bool $isUserSubscribed = null,
?bool $isBlockedByUser = null,
?array $tags = null,
?array $badges = null,
?array $moderators = null,
?string $apId = null,
?string $apProfileId = null,
?int $magazineId = null,
?string $serverSoftware = null,
?string $serverSoftwareVersion = null,
bool $isPostingRestrictedToMods = false,
?int $localSubscribers = null,
?bool $discoverable = null,
?bool $indexable = null,
): self {
$dto = new MagazineResponseDto();
$dto->owner = $owner;
$dto->icon = $icon;
$dto->banner = $banner;
$dto->name = $name;
$dto->title = $title;
$dto->description = $description;
$dto->rules = $rules;
$dto->subscriptionsCount = $subscriptionsCount;
$dto->entryCount = $entryCount;
$dto->entryCommentCount = $entryCommentCount;
$dto->postCount = $postCount;
$dto->postCommentCount = $postCommentCount;
$dto->isAdult = $isAdult;
$dto->isUserSubscribed = $isUserSubscribed;
$dto->isBlockedByUser = $isBlockedByUser;
$dto->tags = $tags;
$dto->badges = $badges;
$dto->moderators = $moderators;
$dto->apId = $apId;
$dto->apProfileId = $apProfileId;
$dto->magazineId = $magazineId;
$dto->serverSoftware = $serverSoftware;
$dto->serverSoftwareVersion = $serverSoftwareVersion;
$dto->isPostingRestrictedToMods = $isPostingRestrictedToMods;
$dto->localSubscribers = $localSubscribers;
$dto->discoverable = $discoverable;
$dto->indexable = $indexable;
return $dto;
}
public function jsonSerialize(): mixed
{
return [
'magazineId' => $this->magazineId,
'owner' => $this->owner?->jsonSerialize(),
'icon' => $this->icon ? $this->icon->jsonSerialize() : null,
'banner' => $this->banner?->jsonSerialize(),
'name' => $this->name,
'title' => $this->title,
'description' => $this->description,
'rules' => $this->rules,
'subscriptionsCount' => $this->subscriptionsCount,
'entryCount' => $this->entryCount,
'entryCommentCount' => $this->entryCommentCount,
'postCount' => $this->postCount,
'postCommentCount' => $this->postCommentCount,
'isAdult' => $this->isAdult,
'isUserSubscribed' => $this->isUserSubscribed,
'isBlockedByUser' => $this->isBlockedByUser,
'tags' => $this->tags,
'badges' => array_map(fn (BadgeResponseDto $badge) => $badge->jsonSerialize(), $this->badges),
'moderators' => array_map(fn (ModeratorResponseDto $moderator) => $moderator->jsonSerialize(), $this->moderators),
'apId' => $this->apId,
'apProfileId' => $this->apProfileId,
'serverSoftware' => $this->serverSoftware,
'serverSoftwareVersion' => $this->serverSoftwareVersion,
'isPostingRestrictedToMods' => $this->isPostingRestrictedToMods,
'localSubscribers' => $this->localSubscribers,
'notificationStatus' => $this->notificationStatus,
'discoverable' => $this->discoverable,
'indexable' => $this->indexable,
];
}
}