From 36ea1db870a0f7a02a08cc7e5d992636d3f16851 Mon Sep 17 00:00:00 2001 From: Galochkin Sergey Date: Sun, 1 Dec 2024 16:33:06 +0300 Subject: [PATCH 1/6] add subscribe and unsubscribe entrypoint --- README.md | 48 +------ docs/ADD_NEW_CARD_ON_BOARD.md | 20 +++ docs/DELETE_EMPTY_BOARD.md | 46 +++++++ docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md | 107 +++++++++++++++ psalm.xml | 1 - src/Actions/Card/CardCreateAction.php | 2 +- .../Card/CardSubscribeMembershipAction.php | 38 ++++++ .../Card/CardUnsubscribeMembershipAction.php | 38 ++++++ .../CardAction/CardActionViewAction.php | 2 +- src/Controllers/Card.php | 29 ++++- src/Traits/BoardHydrateTrait.php | 2 +- src/Traits/CardHydrateTrait.php | 4 +- src/Views/Dto/Card/CardDto.php | 8 +- src/Views/Dto/Card/CardIncludedDto.php | 24 ++++ src/Views/Dto/Project/ProjectIncludedDto.php | 2 +- .../Factory/Board/BoardIncludedDtoFactory.php | 4 +- .../Factory/Card/CardActionListDtoFactory.php | 2 +- src/Views/Factory/Card/CardDtoFactory.php | 122 ++++++++++++++---- .../NotificationIncludedDtoFactory.php | 4 +- tests/subscribe.php | 97 ++++++++++++++ 20 files changed, 512 insertions(+), 88 deletions(-) create mode 100644 docs/ADD_NEW_CARD_ON_BOARD.md create mode 100644 docs/DELETE_EMPTY_BOARD.md create mode 100644 docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md create mode 100644 src/Actions/Card/CardSubscribeMembershipAction.php create mode 100644 src/Actions/Card/CardUnsubscribeMembershipAction.php create mode 100644 src/Views/Dto/Card/CardIncludedDto.php create mode 100644 tests/subscribe.php diff --git a/README.md b/README.md index 57790f0..47bb2d8 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Wrapper over the rest api of the Planka (https://github.com/plankanban/planka) Tested on Planka version: - 1.10.3 - 1.11 + - 1.24.3 Implemented all entrypoints for the bar version **1.10.3** and later. @@ -57,50 +58,11 @@ var_dump($result); ``` +## Examples -### Example - Delete empty board - -```php -authenticate(); - -// Only projects and boards assigned to your user are available -$dto = $planka->project->list(); - -// dd($dto->items); // list projects - -// the list will only contain boards available to your user -$boards = $dto->included->boards; - -/** @var BoardItemDto $item */ -foreach ($boards as $item) { - // we request each board separately - $board = $planka->board->get($item->id); - - // list of board cards - $cardList = $board->included->cards; - - if (empty($cardList)) { - // removing a board without cards - $planka->board->delete($item->id); - } -} -``` +- [Delete empty board](docs/DELETE_EMPTY_BOARD.md) +- [Create new card on board.md](docs/ADD_NEW_CARD_ON_BOARD.md) +- [Subscribe user to card.md](docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md) You can test this bundle for Rest API with a test script, in the folder `/tests/index.php`. There you will find the main examples of using the script. diff --git a/docs/ADD_NEW_CARD_ON_BOARD.md b/docs/ADD_NEW_CARD_ON_BOARD.md new file mode 100644 index 0000000..2741503 --- /dev/null +++ b/docs/ADD_NEW_CARD_ON_BOARD.md @@ -0,0 +1,20 @@ +```shell +1. create card with a name. +2. edit created card, add a description, users +3. labels are added +4. files are added +``` + + +```shell +the output of the script I expected: +1. create Card in Board with id $todo_id +2. name: $todo_name +3. descripion $todo_desc +4. tasks $todo_tasks +5. atachment $todo_atatch +6. members $todo_member +``` + + +https://github.com/plankanban/planka/blob/v1.16.4/server/config/routes.js diff --git a/docs/DELETE_EMPTY_BOARD.md b/docs/DELETE_EMPTY_BOARD.md new file mode 100644 index 0000000..22013fb --- /dev/null +++ b/docs/DELETE_EMPTY_BOARD.md @@ -0,0 +1,46 @@ +### Example - Delete empty board + +```php +authenticate(); + +// Only projects and boards assigned to your user are available +$dto = $planka->project->list(); + +// dd($dto->items); // list projects + +// the list will only contain boards available to your user +$boards = $dto->included->boards; + +/** @var BoardItemDto $item */ +foreach ($boards as $item) { + // we request each board separately + $board = $planka->board->get($item->id); + + // list of board cards + $cardList = $board->included->cards; + + if (empty($cardList)) { + // removing a board without cards + $planka->board->delete($item->id); + } +} +``` + +https://github.com/plankanban/planka/blob/v1.16.4/server/config/routes.js + diff --git a/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md b/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md new file mode 100644 index 0000000..169a619 --- /dev/null +++ b/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md @@ -0,0 +1,107 @@ +# Example Subscribe and Unsubscribe ussr on cards + +```php +getInfo()->getStatusCode() !== 200) { + die('Planka server not connected!'); +} + +if (!$client->authenticate()) { + die('User credentials not corrected!'); +} + +$list = $client->project->list(); + +$project = $list->items[0]; + +$projectInfo = $client->project->get($project->id); + +$boards = []; + +foreach ($list->included->boards as $item) { + if ($item->projectId === $project->id) { + $boards[] = $item; + } +} + +$board = $boards[0]; + +$boardInfo = $client->board->get($board->id); + +$user = $boardInfo->included->users[0]; +$userId = $user->id; + +$cards = []; + +foreach ($boardInfo->included->cards as $item) { + // if user always subscribed - return SERVER ERROR 400 + try { + $cardId = $item->id; + // subscribe user on cards + $client->card->subscribe($cardId, $userId); + } catch (Throwable $e) {} +} + +$boardInfo = $client->board->get($board->id); + +// on $boardInfo->included->cards not have info by memberships +foreach ($boardInfo->included->cards as $item) { + // see memberships at card info + $cardInfo = $client->card->get($item->id); + + $info = [ + 'cardId' => $cardInfo->id, + 'cardName' => $cardInfo->name, + // membershipId not equal userId + 'memberships' => $cardInfo->included->cardMemberships, + 'userId' => map($cardInfo->included->cardMemberships, fn(CardMembershipDto $dto) => [ + 'membershipId' => $dto->id, + 'userId' => $dto->userId, + ]), + ]; + + dump($info); +} + +// If you need unsubscribe user on cards use this - $client->card->unsubscribe($cardId, $userId); +// unsubscribe + +$boardInfo = $client->board->get($board->id); + +foreach ($boardInfo->included->cards as $item) { + // if user always unsubscribed - return SERVER ERROR 400 + try { + $cardId = $item->id; + + // subscribe user on cards + $client->card->unsubscribe($cardId, $userId); + } catch (Throwable $e) {} +} + +``` + + +https://github.com/plankanban/planka/blob/v1.16.4/server/config/routes.js diff --git a/psalm.xml b/psalm.xml index 669ebe1..5c7cb4c 100644 --- a/psalm.xml +++ b/psalm.xml @@ -5,7 +5,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" - findUnusedBaselineEntry="true" > diff --git a/src/Actions/Card/CardCreateAction.php b/src/Actions/Card/CardCreateAction.php index add1e5a..62a94ea 100644 --- a/src/Actions/Card/CardCreateAction.php +++ b/src/Actions/Card/CardCreateAction.php @@ -37,4 +37,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Card/CardSubscribeMembershipAction.php b/src/Actions/Card/CardSubscribeMembershipAction.php new file mode 100644 index 0000000..fa76b25 --- /dev/null +++ b/src/Actions/Card/CardSubscribeMembershipAction.php @@ -0,0 +1,38 @@ +setToken($token); + } + + public function url(): string + { + return "api/cards/{$this->cardId}/memberships"; + } + + public function getOptions(): array + { + return [ + 'body' => [ + 'userId' => $this->userId, + ], + ]; + } +} diff --git a/src/Actions/Card/CardUnsubscribeMembershipAction.php b/src/Actions/Card/CardUnsubscribeMembershipAction.php new file mode 100644 index 0000000..4165e3f --- /dev/null +++ b/src/Actions/Card/CardUnsubscribeMembershipAction.php @@ -0,0 +1,38 @@ +setToken($token); + } + + public function url(): string + { + return "api/cards/{$this->cardId}/memberships"; + } + + public function getOptions(): array + { + return [ + 'body' => [ + 'userId' => $this->userId, + ], + ]; + } +} diff --git a/src/Actions/CardAction/CardActionViewAction.php b/src/Actions/CardAction/CardActionViewAction.php index ca6b2db..e86771a 100644 --- a/src/Actions/CardAction/CardActionViewAction.php +++ b/src/Actions/CardAction/CardActionViewAction.php @@ -39,4 +39,4 @@ public function hydrate(ResponseInterface $response): CardActionListDto { return (new CardActionListDtoFactory())->create($response->toArray()); } -} \ No newline at end of file +} diff --git a/src/Controllers/Card.php b/src/Controllers/Card.php index 88c428f..5052455 100644 --- a/src/Controllers/Card.php +++ b/src/Controllers/Card.php @@ -4,12 +4,15 @@ namespace Planka\Bridge\Controllers; +use Planka\Bridge\Actions\Card\CardUnsubscribeMembershipAction; +use Planka\Bridge\Actions\Card\CardSubscribeMembershipAction; use Planka\Bridge\Actions\Card\CardClearDueDateAction; -use Planka\Bridge\Actions\Card\CardTimerAction; +use Planka\Bridge\Views\Dto\Card\CardMembershipDto; use Planka\Bridge\Actions\Card\CardCreateAction; use Planka\Bridge\Actions\Card\CardDeleteAction; -use Planka\Bridge\Actions\Card\CardMoveAction; use Planka\Bridge\Actions\Card\CardUpdateAction; +use Planka\Bridge\Actions\Card\CardTimerAction; +use Planka\Bridge\Actions\Card\CardMoveAction; use Planka\Bridge\Actions\Card\CardViewAction; use Planka\Bridge\TransportClients\Client; use Planka\Bridge\Views\Dto\Card\CardDto; @@ -92,4 +95,24 @@ public function delete(string $cardId): void { $this->client->delete(new CardDeleteAction(cardId: $cardId, token: $this->config->getAuthToken())); } -} \ No newline at end of file + + /** 'POST /api/cards/:cardId/memberships' */ + public function subscribe(string $cardId, string $userId): CardMembershipDto + { + return $this->client->post(new CardSubscribeMembershipAction( + cardId: $cardId, + userId: $userId, + token: $this->config->getAuthToken() + )); + } + + /** 'DELETE /api/cards/:cardId/memberships' */ + public function unsubscribe(string $cardId, string $userId): CardMembershipDto + { + return $this->client->delete(new CardUnsubscribeMembershipAction( + cardId: $cardId, + userId: $userId, + token: $this->config->getAuthToken() + )); + } +} diff --git a/src/Traits/BoardHydrateTrait.php b/src/Traits/BoardHydrateTrait.php index 44909be..54edc97 100644 --- a/src/Traits/BoardHydrateTrait.php +++ b/src/Traits/BoardHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): BoardDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/CardHydrateTrait.php b/src/Traits/CardHydrateTrait.php index a367377..1bad5f1 100644 --- a/src/Traits/CardHydrateTrait.php +++ b/src/Traits/CardHydrateTrait.php @@ -29,9 +29,9 @@ final public function hydrate(ResponseInterface $response): CardDto $result = $response->toArray(); if (array_key_exists('item', $result)) { - return (new CardDtoFactory())->create($result['item']); + return (new CardDtoFactory())->create($result); } throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Views/Dto/Card/CardDto.php b/src/Views/Dto/Card/CardDto.php index 3686b43..334af2a 100644 --- a/src/Views/Dto/Card/CardDto.php +++ b/src/Views/Dto/Card/CardDto.php @@ -13,16 +13,18 @@ public function __construct( public readonly string $id, public readonly DateTimeImmutable $createdAt, public readonly ?DateTimeImmutable $updatedAt, - public readonly string $creatorUserId, public int $position, public string $name, public ?string $description, public ?DateTimeImmutable $dueDate, + public readonly ?bool $isDueDateCompleted, public ?StopWatchDto $stopwatch, public string $boardId, public string $listId, + public string $creatorUserId, public ?string $coverAttachmentId, - public bool $isSubscribed + public readonly bool $isSubscribed, + public readonly CardIncludedDto $included ) { } -} \ No newline at end of file +} diff --git a/src/Views/Dto/Card/CardIncludedDto.php b/src/Views/Dto/Card/CardIncludedDto.php new file mode 100644 index 0000000..a49a09e --- /dev/null +++ b/src/Views/Dto/Card/CardIncludedDto.php @@ -0,0 +1,24 @@ + $cardMemberships + * @param list $cardLabels + * @param list $tasks + * @param list $attachments + */ + public function __construct( + public array $cardMemberships, + public array $cardLabels, + public array $tasks, + public array $attachments + ) { + } +} diff --git a/src/Views/Dto/Project/ProjectIncludedDto.php b/src/Views/Dto/Project/ProjectIncludedDto.php index 01783c1..7299e09 100644 --- a/src/Views/Dto/Project/ProjectIncludedDto.php +++ b/src/Views/Dto/Project/ProjectIncludedDto.php @@ -24,4 +24,4 @@ public function __construct( public array $boardMemberships ) { } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Board/BoardIncludedDtoFactory.php b/src/Views/Factory/Board/BoardIncludedDtoFactory.php index c3c2b17..e628977 100644 --- a/src/Views/Factory/Board/BoardIncludedDtoFactory.php +++ b/src/Views/Factory/Board/BoardIncludedDtoFactory.php @@ -118,7 +118,7 @@ private function getLists(array $data): array private function getCards(array $data): array { return map($data['cards'] ?? [], - fn(array $item) => (new CardDtoFactory())->create($item) + fn(array $item) => (new CardDtoFactory())->create(['item' => $item]) ); } @@ -171,4 +171,4 @@ private function getProjects(array $data): array fn(array $item) => (new ProjectDtoFactory())->create($item) ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Card/CardActionListDtoFactory.php b/src/Views/Factory/Card/CardActionListDtoFactory.php index 4f3a49a..fe95c01 100644 --- a/src/Views/Factory/Card/CardActionListDtoFactory.php +++ b/src/Views/Factory/Card/CardActionListDtoFactory.php @@ -67,4 +67,4 @@ private function getIncluded(array $data): array { return map($data['included']['users'] ?? [], fn(array $item) => (new UserDtoFactory())->create($item)); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Card/CardDtoFactory.php b/src/Views/Factory/Card/CardDtoFactory.php index c53a12b..e421b23 100644 --- a/src/Views/Factory/Card/CardDtoFactory.php +++ b/src/Views/Factory/Card/CardDtoFactory.php @@ -7,6 +7,9 @@ use Planka\Bridge\Contracts\Factory\OutputInterface; use Planka\Bridge\Traits\DateConverterTrait; use Planka\Bridge\Views\Dto\Card\CardDto; +use Planka\Bridge\Views\Dto\Card\CardIncludedDto; +use Planka\Bridge\Views\Factory\Attachment\AttachmentDtoFactory; +use function Fp\Collection\map; final class CardDtoFactory implements OutputInterface { @@ -14,38 +17,103 @@ final class CardDtoFactory implements OutputInterface /** * @param array{ - * id: string, - * createdAt: string, - * updatedAt: ?string, - * position: int, - * name: string, - * description: ?string, - * dueDate: ?string, - * stopwatch: array, - * boardId: string, - * listId: ?string, - * creatorUserId: string, - * coverAttachmentId: ?string, - * isSubscribed: ?bool + * item: array { + * id: string, + * createdAt: string, + * updatedAt: ?string, + * position: int, + * name: string, + * description: ?string, + * dueDate: ?string, + * isDueDateCompleted: ?bool, + * stopwatch: ?array, + * boardId: string, + * listId: ?string, + * creatorUserId: string, + * coverAttachmentId: ?string, + * isSubscribed: ?bool + * }, + * included: array { + * cardMemberships: ?array{ + * id: string, + * createdAt: string, + * updatedAt: ?string, + * cardId: string, + * userId: string + * }, + * cardLabels: ?array { + * id: string, + * createdAt: string, + * updatedAt: ?string, + * cardId: string, + * labelId: string + * }, + * tasks: ?array { + * id: string, + * createdAt: string, + * updatedAt: ?string, + * position: int, + * name: string, + * isCompleted: bool, + * cardId: string, + * }, + * attachments: ?array { + * id: string, + * createdAt: string, + * updatedAt: ?string, + * updatedAt: array { + * width: int, + * height: int + * }, + * name: string, + * cardId: string, + * creatorUserId: string, + * url: string, + * coverUrl: string + * }, + * } * } $data * @return CardDto */ public function create(array $data): CardDto { + $item = $data['item']; + return new CardDto( - id: $data['id'], - createdAt: $this->convertToDateTime($data['createdAt']), - updatedAt: $this->convertToDateTime($data['updatedAt']), - creatorUserId: $data['creatorUserId'], - position: (int)$data['position'], - name: $data['name'], - description: $data['description'], - dueDate: $this->convertToDateTime($data['dueDate']), - stopwatch: (new StopWatchDtoFactory())->create($data['stopwatch']), - boardId: $data['boardId'], - listId: $data['listId'], - coverAttachmentId: $data['coverAttachmentId'], - isSubscribed: (bool)($data['isSubscribed'] ?? false) + id: $item['id'], + createdAt: $this->convertToDateTime($item['createdAt']), + updatedAt: $this->convertToDateTime($item['updatedAt']), + position: (int)$item['position'], + name: $item['name'], + description: $item['description'], + dueDate: $this->convertToDateTime($item['dueDate']), + isDueDateCompleted: $item['isDueDateCompleted'], + stopwatch: (new StopWatchDtoFactory())->create($item['stopwatch']), + boardId: $item['boardId'], + listId: $item['listId'], + creatorUserId: $item['creatorUserId'], + coverAttachmentId: $item['coverAttachmentId'], + isSubscribed: (bool)($item['isSubscribed'] ?? false), + included: $this->getIncluded($data) + ); + } + + private function getIncluded(array $data): CardIncludedDto + { + if (!isset($data['included'])) { + return new CardIncludedDto( + cardMemberships: [], + cardLabels: [], + tasks: [], + attachments: [] + ); + } + + return new CardIncludedDto( + cardMemberships: map($data['included']['cardMemberships'] ?? [], fn(array $item) => (new CardMembershipDtoFactory())->create($item)), + cardLabels: map($data['included']['cardLabels'] ?? [], fn(array $item) => (new CardLabelDtoFactory())->create($item)), + tasks: map($data['included']['tasks'] ?? [], fn(array $item) => (new CardTaskDtoFactory())->create($item)), + attachments: map($data['included']['attachments'] ?? [], fn(array $item) => (new AttachmentDtoFactory())->create($item)) ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Notification/NotificationIncludedDtoFactory.php b/src/Views/Factory/Notification/NotificationIncludedDtoFactory.php index 2011289..4bce90f 100644 --- a/src/Views/Factory/Notification/NotificationIncludedDtoFactory.php +++ b/src/Views/Factory/Notification/NotificationIncludedDtoFactory.php @@ -47,7 +47,7 @@ private function getUsers(array $data): array private function getCards(array $data): array { return map($data['cards'] ?? [], - fn(array $item) => (new CardDtoFactory())->create($item) + fn(array $item) => (new CardDtoFactory())->create(['item' => $item]) ); } @@ -60,4 +60,4 @@ private function getActions(array $data): array fn(array $item) => (new CardActionItemDtoFactory())->create($item) ); } -} \ No newline at end of file +} diff --git a/tests/subscribe.php b/tests/subscribe.php new file mode 100644 index 0000000..ec61df6 --- /dev/null +++ b/tests/subscribe.php @@ -0,0 +1,97 @@ +getInfo()->getStatusCode() !== 200) { + die('Planka server not connected!'); +} + +if (!$client->authenticate()) { + die('User credentials not corrected!'); +} + +$list = $client->project->list(); + +$project = $list->items[0]; + +$projectInfo = $client->project->get($project->id); + +$boards = []; + +foreach ($list->included->boards as $item) { + if ($item->projectId === $project->id) { + $boards[] = $item; + } +} + +$board = $boards[0]; + +$boardInfo = $client->board->get($board->id); + +$user = $boardInfo->included->users[0]; +$userId = $user->id; + +$cards = []; + +foreach ($boardInfo->included->cards as $item) { + // if user always subscribed - return SERVER ERROR 400 + try { + $cardId = $item->id; + // subscribe user on cards + $client->card->subscribe($cardId, $userId); + } catch (Throwable $e) {} +} + +$boardInfo = $client->board->get($board->id); + +foreach ($boardInfo->included->cards as $item) { + // see user id in + $cardInfo = $client->card->get($item->id); + + $info = [ + 'cardId' => $cardInfo->id, + 'cardName' => $cardInfo->name, + // membershipId not equal userId + 'memberships' => $cardInfo->included->cardMemberships, + 'userId' => map($cardInfo->included->cardMemberships, fn(CardMembershipDto $dto) => [ + 'membershipId' => $dto->id, + 'userId' => $dto->userId, + ]), + ]; + + dump($info); +} + +// unsubscribe + +$boardInfo = $client->board->get($board->id); + +foreach ($boardInfo->included->cards as $item) { + // if user always unsubscribed - return SERVER ERROR 400 + try { + $cardId = $item->id; + + // subscribe user on cards + $client->card->unsubscribe($cardId, $userId); + } catch (Throwable $e) {} +} From 0ea7b51f338f85a826ed5677b17e820d1d1f7f75 Mon Sep 17 00:00:00 2001 From: Galochkin Sergey Date: Sun, 1 Dec 2024 16:33:17 +0300 Subject: [PATCH 2/6] fix crashed action --- src/Actions/Card/CardTimerAction.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Actions/Card/CardTimerAction.php b/src/Actions/Card/CardTimerAction.php index 2092ba5..63de237 100644 --- a/src/Actions/Card/CardTimerAction.php +++ b/src/Actions/Card/CardTimerAction.php @@ -7,10 +7,10 @@ use Planka\Bridge\Contracts\Actions\ResponseResultInterface; use Planka\Bridge\Contracts\Actions\AuthenticateInterface; use Planka\Bridge\Contracts\Actions\ActionInterface; +use Planka\Bridge\Views\Dto\Card\StopWatchDto; use Planka\Bridge\Traits\AuthenticateTrait; use Planka\Bridge\Traits\CardHydrateTrait; use Planka\Bridge\Views\Dto\Card\CardDto; -use Planka\Bridge\Views\Dto\Card\StopWatchDto; use DateTimeImmutable; final class CardTimerAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface @@ -42,11 +42,14 @@ public function getOptions(): array // stop timer if (!$this->start) { - $diff = time() - $this->card->stopwatch->startedAt->getTimestamp(); - $total = $this->card->stopwatch->total + $diff; - $stopwatch = new StopWatchDto(null, $total); - - $this->card->stopwatch = $stopwatch; + if ($this->card->stopwatch !== null) { + $diff = time() - $this->card->stopwatch->startedAt->getTimestamp(); + $total = $this->card->stopwatch->total + $diff; + + $stopwatch = new StopWatchDto(null, $total); + + $this->card->stopwatch = $stopwatch; + } } return [ @@ -70,4 +73,4 @@ private function tickingWatch(): StopWatchDto return new StopWatchDto(new DateTimeImmutable(), 0); } -} \ No newline at end of file +} From 594316441d2bc4652adb223f2f467f8816ace060 Mon Sep 17 00:00:00 2001 From: Galochkin Sergey Date: Sun, 1 Dec 2024 20:48:41 +0300 Subject: [PATCH 3/6] add code style fixer cs-fixer --- .gitignore | 5 +- .php-cs-fixer.dist.php | 34 ++++++++++++ composer.json | 16 ++++-- .../Attachment/AttachmentCreateAction.php | 7 +-- .../Attachment/AttachmentDeleteAction.php | 5 +- .../Attachment/AttachmentUpdateAction.php | 7 +-- src/Actions/Auth/AuthenticateAction.php | 4 +- src/Actions/Auth/LogoutAction.php | 2 +- src/Actions/Board/BoardCreateAction.php | 7 +-- src/Actions/Board/BoardDeleteAction.php | 5 +- src/Actions/Board/BoardUpdateAction.php | 7 +-- src/Actions/Board/BoardViewAction.php | 5 +- .../BoardList/BoardListCreateAction.php | 7 +-- .../BoardList/BoardListDeleteAction.php | 5 +- .../BoardList/BoardListUpdateAction.php | 7 +-- .../BoardMembershipAddAction.php | 7 +-- .../BoardMembershipDeleteAction.php | 5 +- .../BoardMembershipUpdateAction.php | 5 +- src/Actions/Card/CardClearDueDateAction.php | 5 +- src/Actions/Card/CardCreateAction.php | 5 +- src/Actions/Card/CardDeleteAction.php | 2 +- src/Actions/Card/CardMoveAction.php | 5 +- .../Card/CardSubscribeMembershipAction.php | 5 +- src/Actions/Card/CardTimerAction.php | 14 ++--- .../Card/CardUnsubscribeMembershipAction.php | 5 +- src/Actions/Card/CardUpdateAction.php | 11 ++-- src/Actions/Card/CardViewAction.php | 5 +- .../CardLabel/CardLabelCreateAction.php | 7 +-- .../CardLabel/CardLabelDeleteAction.php | 7 +-- .../CardMembershipCreateAction.php | 7 +-- .../CardMembershipDeleteAction.php | 7 +-- src/Actions/CardTask/CardTaskCreateAction.php | 5 +- src/Actions/CardTask/CardTaskDeleteAction.php | 5 +- src/Actions/CardTask/CardTaskUpdateAction.php | 5 +- src/Actions/Comment/CommentCreateAction.php | 7 +-- src/Actions/Comment/CommentDeleteAction.php | 5 +- src/Actions/Comment/CommentUpdateAction.php | 7 +-- src/Actions/Common/GetInfoAction.php | 2 +- src/Actions/Label/LabelCreateAction.php | 7 +-- src/Actions/Label/LabelDeleteAction.php | 5 +- src/Actions/Label/LabelUpdateAction.php | 7 +-- .../Notification/NotificationListAction.php | 4 +- .../Notification/NotificationUpdateAction.php | 6 ++- .../Notification/NotificationVewAction.php | 5 +- src/Actions/Project/ProjectCreateAction.php | 7 +-- src/Actions/Project/ProjectDeleteAction.php | 5 +- src/Actions/Project/ProjectListAction.php | 8 ++- src/Actions/Project/ProjectUpdateAction.php | 17 +++--- .../ProjectUpdateBackgroundImageAction.php | 16 +++--- src/Actions/Project/ProjectViewAction.php | 5 +- .../ProjectManagerCreateAction.php | 7 +-- .../ProjectManagerDeleteAction.php | 5 +- src/Actions/User/UserCreateAction.php | 5 +- src/Actions/User/UserDeleteAction.php | 5 +- src/Actions/User/UserListAction.php | 5 +- src/Actions/User/UserUpdateAction.php | 5 +- src/Actions/User/UserUpdateAvatarAction.php | 7 +-- src/Actions/User/UserUpdateEmailAction.php | 3 +- src/Actions/User/UserUpdatePasswordAction.php | 7 +-- src/Actions/User/UserUpdateUsernameAction.php | 5 +- src/Actions/User/UserViewAction.php | 5 +- src/Config.php | 5 +- src/Contracts/Actions/ActionInterface.php | 4 +- .../Actions/AuthenticateInterface.php | 4 +- .../Actions/ResponseResultInterface.php | 4 +- src/Contracts/Dto/OutputDtoInterface.php | 6 +-- src/Contracts/Factory/OutputInterface.php | 5 +- src/Controllers/Attachment.php | 16 +++--- src/Controllers/Board.php | 11 ++-- src/Controllers/BoardList.php | 11 ++-- src/Controllers/BoardMembership.php | 15 +++--- src/Controllers/Card.php | 21 ++++---- src/Controllers/CardAction.php | 7 ++- src/Controllers/CardLabel.php | 11 ++-- src/Controllers/CardMembership.php | 11 ++-- src/Controllers/CardTask.php | 11 ++-- src/Controllers/Comment.php | 13 +++-- src/Controllers/Label.php | 11 ++-- src/Controllers/Notification.php | 21 ++++---- src/Controllers/Project.php | 17 +++--- src/Controllers/ProjectManager.php | 16 +++--- src/Controllers/User.php | 19 +++---- src/Enum/BackgroundGradientEnum.php | 6 ++- src/Enum/BackgroundTypeEnum.php | 2 + src/Enum/BoardMembershipRoleEnum.php | 2 + src/Enum/CommentTypeEnum.php | 2 + src/Enum/LabelColorEnum.php | 2 + src/Exceptions/AuthenticateException.php | 8 ++- src/Exceptions/FileExistException.php | 8 ++- src/Exceptions/LogoutException.php | 8 ++- src/Exceptions/ResponseException.php | 8 ++- src/Exceptions/ValidateException.php | 8 ++- src/PlankaClient.php | 32 ++++++++--- src/Traits/AttachmentHydrateTrait.php | 2 +- src/Traits/AuthenticateTrait.php | 2 +- src/Traits/BoardListHydrateTrait.php | 2 +- src/Traits/BoardMembershipHydrateTrait.php | 2 +- src/Traits/CardLabelHydrateTrait.php | 2 +- src/Traits/CardMembershipHydrateTrait.php | 2 +- src/Traits/CardTaskHydrateTrait.php | 2 +- src/Traits/CommentHydrateTrait.php | 2 +- src/Traits/DateConverterTrait.php | 11 ++-- src/Traits/LabelHydrateTrait.php | 2 +- src/Traits/NotificationHydrateTrait.php | 2 +- src/Traits/ProjectHydrateTrait.php | 2 +- src/Traits/ProjectManagerHydrateTrait.php | 2 +- src/Traits/UserHydrateTrait.php | 4 +- src/TransportClients/Client.php | 19 +++---- src/Views/Dto/Attachment/AttachmentDto.php | 12 ++--- src/Views/Dto/Background/BackgroundDto.php | 5 +- .../Dto/Background/BackgroundImageDto.php | 7 ++- src/Views/Dto/Board/BoardDto.php | 7 ++- src/Views/Dto/Board/BoardIncludedDto.php | 23 ++++---- src/Views/Dto/Board/BoardItemDto.php | 10 ++-- src/Views/Dto/Board/BoardListDto.php | 11 ++-- src/Views/Dto/Board/BoardMembershipDto.php | 10 ++-- src/Views/Dto/Card/CardActionItemDto.php | 12 ++--- src/Views/Dto/Card/CardActionListDto.php | 7 ++- src/Views/Dto/Card/CardDto.php | 12 ++--- src/Views/Dto/Card/CardIncludedDto.php | 13 +++-- src/Views/Dto/Card/CardLabelDto.php | 12 ++--- src/Views/Dto/Card/CardMembershipDto.php | 12 ++--- src/Views/Dto/Card/CardTaskDto.php | 12 ++--- src/Views/Dto/Card/StopWatchDto.php | 11 ++-- src/Views/Dto/Comment/CommentDto.php | 12 ++--- src/Views/Dto/Image/ImageDto.php | 7 ++- src/Views/Dto/Label/LabelDto.php | 10 ++-- src/Views/Dto/List/ListDto.php | 11 ++-- .../Notification/NotificationIncludedDto.php | 7 ++- .../Dto/Notification/NotificationItemDto.php | 13 ++--- .../Dto/Notification/NotificationListDto.php | 6 +-- src/Views/Dto/Project/ProjectDto.php | 12 ++--- src/Views/Dto/Project/ProjectIncludedDto.php | 11 ++-- src/Views/Dto/Project/ProjectListDto.php | 8 ++- src/Views/Dto/User/UserDto.php | 14 +++-- .../Attachment/AttachmentDtoFactory.php | 5 +- .../Background/BackgroundDtoFactory.php | 5 +- .../Background/BackgroundImageDtoFactory.php | 5 +- src/Views/Factory/Board/BoardDtoFactory.php | 2 +- .../Factory/Board/BoardIncludedDtoFactory.php | 53 +++++++++++-------- .../Factory/Board/BoardItemDtoFactory.php | 7 ++- .../Factory/Board/BoardListDtoFactory.php | 7 ++- .../Board/BoardMembershipDtoFactory.php | 7 ++- .../Factory/Card/CardActionItemDtoFactory.php | 3 +- .../Factory/Card/CardActionListDtoFactory.php | 4 +- src/Views/Factory/Card/CardDtoFactory.php | 16 +++--- .../Factory/Card/CardLabelDtoFactory.php | 5 +- .../Factory/Card/CardMembershipDtoFactory.php | 5 +- src/Views/Factory/Card/CardTaskDtoFactory.php | 9 ++-- .../Factory/Card/StopWatchDtoFactory.php | 4 +- .../Factory/Comment/CommentDtoFactory.php | 5 +- src/Views/Factory/Image/ImageDtoFactory.php | 6 +-- src/Views/Factory/Label/LabelDtoFactory.php | 7 ++- src/Views/Factory/List/ListDtoFactory.php | 7 ++- .../NotificationIncludedDtoFactory.php | 14 ++--- .../NotificationItemDtoFactory.php | 7 ++- .../NotificationListDtoFactory.php | 6 +-- .../Factory/Project/ProjectDtoFactory.php | 5 +- .../Project/ProjectIncludedDtoFactory.php | 13 +++-- .../Factory/Project/ProjectListDtoFactory.php | 11 ++-- .../Factory/Project/ProjectManagerDto.php | 15 +++--- .../Project/ProjectManagerDtoFactory.php | 7 ++- src/Views/Factory/User/UserDtoFactory.php | 9 ++-- tests/config.example.php | 4 +- tests/index.php | 18 ++++--- tests/subscribe.php | 17 +++--- 166 files changed, 712 insertions(+), 658 deletions(-) create mode 100755 .php-cs-fixer.dist.php diff --git a/.gitignore b/.gitignore index 5830ded..eb55315 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ composer.lock .idea index.php -config.php \ No newline at end of file +config.php +/.php-cs-fixer.php +/.php-cs-fixer.cache +/var/.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100755 index 0000000..d833dad --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,34 @@ +exclude(['var', 'tests/Support/_generated', 'tests/_output']) + ->name('*.php') + ->in([__DIR__.'/src', __DIR__.'/tests']) +; + +return (new PhpCsFixer\Config()) + ->setRiskyAllowed(true) + ->setCacheFile(__DIR__ . '/var/.php-cs-fixer.cache') + ->setRules([ + '@Symfony' => true, + '@PER-CS2.0' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'const' => 'none', + 'method' => 'one', + 'property' => 'one', + 'trait_import' => 'none', + 'case' => 'none', + ], + ], + 'strict_param' => true, + 'array_syntax' => ['syntax' => 'short'], + 'function_declaration' => false, + 'declare_strict_types' => true, + 'set_type_to_cast' => true, + 'no_alternative_syntax' => ['fix_non_monolithic_code' => true], + ]) + ->setFinder($finder) +; diff --git a/composer.json b/composer.json index a13a7a6..f10f3cb 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,9 @@ "email": "airy@live.com" } ], + "minimum-stability": "dev", + "prefer-stable": true, + "version": "1.1.4", "require": { "php": ">=8.1.0", "symfony/http-client": "^6.2", @@ -31,11 +34,14 @@ "dev-master": "0.1-dev" } }, - "minimum-stability": "dev", - "prefer-stable": true, - "version": "1.1.4", + "scripts": { + "fix-cs": [ + "@php ./vendor/bin/php-cs-fixer fix --diff -v --allow-risky=yes --ansi" + ] + }, "require-dev": { "symfony/var-dumper": "^6.2", - "vimeo/psalm": "^5.11" + "vimeo/psalm": "^5.11", + "friendsofphp/php-cs-fixer": "^3.65" } -} \ No newline at end of file +} diff --git a/src/Actions/Attachment/AttachmentCreateAction.php b/src/Actions/Attachment/AttachmentCreateAction.php index 13f5829..bab27d4 100644 --- a/src/Actions/Attachment/AttachmentCreateAction.php +++ b/src/Actions/Attachment/AttachmentCreateAction.php @@ -15,7 +15,8 @@ final class AttachmentCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, AttachmentHydrateTrait; + use AuthenticateTrait; + use AttachmentHydrateTrait; /** * @throws FileExistException @@ -23,7 +24,7 @@ final class AttachmentCreateAction implements ActionInterface, AuthenticateInter public function __construct( private readonly string $cardId, private readonly string $file, - string $token + string $token, ) { $this->setToken($token); @@ -49,4 +50,4 @@ public function getOptions(): array 'body' => $formData->bodyToIterable(), ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Attachment/AttachmentDeleteAction.php b/src/Actions/Attachment/AttachmentDeleteAction.php index fcef46a..fb0d251 100644 --- a/src/Actions/Attachment/AttachmentDeleteAction.php +++ b/src/Actions/Attachment/AttachmentDeleteAction.php @@ -12,7 +12,8 @@ final class AttachmentDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, AttachmentHydrateTrait; + use AuthenticateTrait; + use AttachmentHydrateTrait; public function __construct(private readonly string $attachmentId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/Attachment/AttachmentUpdateAction.php b/src/Actions/Attachment/AttachmentUpdateAction.php index 4be237d..6296212 100644 --- a/src/Actions/Attachment/AttachmentUpdateAction.php +++ b/src/Actions/Attachment/AttachmentUpdateAction.php @@ -12,12 +12,13 @@ final class AttachmentUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, AttachmentHydrateTrait; + use AuthenticateTrait; + use AttachmentHydrateTrait; public function __construct( private readonly string $attachmentId, private readonly string $name, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Auth/AuthenticateAction.php b/src/Actions/Auth/AuthenticateAction.php index de15b23..3f961dc 100644 --- a/src/Actions/Auth/AuthenticateAction.php +++ b/src/Actions/Auth/AuthenticateAction.php @@ -15,7 +15,7 @@ public function __construct(string $username, string $password) { $formFields = [ 'emailOrUsername' => $username, - 'password' => $password + 'password' => $password, ]; $formData = new FormDataPart($formFields); $this->options['headers'] = $formData->getPreparedHeaders()->toArray(); @@ -31,4 +31,4 @@ public function getOptions(): array { return $this->options; } -} \ No newline at end of file +} diff --git a/src/Actions/Auth/LogoutAction.php b/src/Actions/Auth/LogoutAction.php index 4e02dfd..60c7e9a 100644 --- a/src/Actions/Auth/LogoutAction.php +++ b/src/Actions/Auth/LogoutAction.php @@ -26,4 +26,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/Board/BoardCreateAction.php b/src/Actions/Board/BoardCreateAction.php index 6811aec..55a1b89 100644 --- a/src/Actions/Board/BoardCreateAction.php +++ b/src/Actions/Board/BoardCreateAction.php @@ -12,13 +12,14 @@ final class BoardCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardHydrateTrait; + use AuthenticateTrait; + use BoardHydrateTrait; public function __construct( private readonly string $projectId, private readonly string $name, private readonly int $position, - string $token + string $token, ) { $this->setToken($token); } @@ -37,4 +38,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Board/BoardDeleteAction.php b/src/Actions/Board/BoardDeleteAction.php index ed5add4..5af9be7 100644 --- a/src/Actions/Board/BoardDeleteAction.php +++ b/src/Actions/Board/BoardDeleteAction.php @@ -12,7 +12,8 @@ final class BoardDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardHydrateTrait; + use AuthenticateTrait; + use BoardHydrateTrait; public function __construct(private readonly string $boardId, string $token) { @@ -30,4 +31,4 @@ public function getOptions(): array 'body' => [], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Board/BoardUpdateAction.php b/src/Actions/Board/BoardUpdateAction.php index 8244ad3..868d4df 100644 --- a/src/Actions/Board/BoardUpdateAction.php +++ b/src/Actions/Board/BoardUpdateAction.php @@ -12,12 +12,13 @@ final class BoardUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardHydrateTrait; + use AuthenticateTrait; + use BoardHydrateTrait; public function __construct( private readonly string $boardId, private readonly string $name, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Board/BoardViewAction.php b/src/Actions/Board/BoardViewAction.php index 072f880..1a5c0b9 100644 --- a/src/Actions/Board/BoardViewAction.php +++ b/src/Actions/Board/BoardViewAction.php @@ -12,7 +12,8 @@ final class BoardViewAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardHydrateTrait; + use AuthenticateTrait; + use BoardHydrateTrait; public function __construct(private readonly string $boardId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/BoardList/BoardListCreateAction.php b/src/Actions/BoardList/BoardListCreateAction.php index 9613e6d..46fb934 100644 --- a/src/Actions/BoardList/BoardListCreateAction.php +++ b/src/Actions/BoardList/BoardListCreateAction.php @@ -12,13 +12,14 @@ final class BoardListCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardListHydrateTrait; + use AuthenticateTrait; + use BoardListHydrateTrait; public function __construct( private readonly string $boardId, private readonly string $name, private readonly int $position, - string $token + string $token, ) { $this->setToken($token); } @@ -37,4 +38,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/BoardList/BoardListDeleteAction.php b/src/Actions/BoardList/BoardListDeleteAction.php index c4f178e..498dfe5 100644 --- a/src/Actions/BoardList/BoardListDeleteAction.php +++ b/src/Actions/BoardList/BoardListDeleteAction.php @@ -12,7 +12,8 @@ final class BoardListDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardListHydrateTrait; + use AuthenticateTrait; + use BoardListHydrateTrait; public function __construct(private readonly string $listId, string $token) { @@ -30,4 +31,4 @@ public function getOptions(): array 'body' => [], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/BoardList/BoardListUpdateAction.php b/src/Actions/BoardList/BoardListUpdateAction.php index 019992f..f3d7368 100644 --- a/src/Actions/BoardList/BoardListUpdateAction.php +++ b/src/Actions/BoardList/BoardListUpdateAction.php @@ -12,12 +12,13 @@ final class BoardListUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardListHydrateTrait; + use AuthenticateTrait; + use BoardListHydrateTrait; public function __construct( private readonly string $listId, private readonly string $name, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/BoardMembership/BoardMembershipAddAction.php b/src/Actions/BoardMembership/BoardMembershipAddAction.php index 3cd4460..0243252 100644 --- a/src/Actions/BoardMembership/BoardMembershipAddAction.php +++ b/src/Actions/BoardMembership/BoardMembershipAddAction.php @@ -13,13 +13,14 @@ final class BoardMembershipAddAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardMembershipHydrateTrait; + use AuthenticateTrait; + use BoardMembershipHydrateTrait; public function __construct( private readonly string $boardId, private readonly string $userId, private readonly BoardMembershipRoleEnum $role, - string $token + string $token, ) { $this->setToken($token); } @@ -38,4 +39,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/BoardMembership/BoardMembershipDeleteAction.php b/src/Actions/BoardMembership/BoardMembershipDeleteAction.php index 5a56198..f4770b2 100644 --- a/src/Actions/BoardMembership/BoardMembershipDeleteAction.php +++ b/src/Actions/BoardMembership/BoardMembershipDeleteAction.php @@ -12,7 +12,8 @@ final class BoardMembershipDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardMembershipHydrateTrait; + use AuthenticateTrait; + use BoardMembershipHydrateTrait; public function __construct(private readonly string $membership, string $token) { @@ -30,4 +31,4 @@ public function getOptions(): array 'body' => [], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/BoardMembership/BoardMembershipUpdateAction.php b/src/Actions/BoardMembership/BoardMembershipUpdateAction.php index dbe1bb1..5f65cc3 100644 --- a/src/Actions/BoardMembership/BoardMembershipUpdateAction.php +++ b/src/Actions/BoardMembership/BoardMembershipUpdateAction.php @@ -13,7 +13,8 @@ final class BoardMembershipUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, BoardMembershipHydrateTrait; + use AuthenticateTrait; + use BoardMembershipHydrateTrait; public function __construct( private readonly string $membershipId, @@ -38,4 +39,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Card/CardClearDueDateAction.php b/src/Actions/Card/CardClearDueDateAction.php index 499863b..a1f8ab1 100644 --- a/src/Actions/Card/CardClearDueDateAction.php +++ b/src/Actions/Card/CardClearDueDateAction.php @@ -13,7 +13,8 @@ final class CardClearDueDateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardHydrateTrait; + use AuthenticateTrait; + use CardHydrateTrait; public function __construct(private readonly CardDto $card, string $token) { @@ -33,4 +34,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Card/CardCreateAction.php b/src/Actions/Card/CardCreateAction.php index 62a94ea..903fe59 100644 --- a/src/Actions/Card/CardCreateAction.php +++ b/src/Actions/Card/CardCreateAction.php @@ -12,13 +12,14 @@ final class CardCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardHydrateTrait; + use AuthenticateTrait; + use CardHydrateTrait; public function __construct( private readonly string $listId, private readonly string $name, private readonly int $position, - string $token + string $token, ) { $this->setToken($token); } diff --git a/src/Actions/Card/CardDeleteAction.php b/src/Actions/Card/CardDeleteAction.php index 22beb71..a85492f 100644 --- a/src/Actions/Card/CardDeleteAction.php +++ b/src/Actions/Card/CardDeleteAction.php @@ -26,4 +26,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/Card/CardMoveAction.php b/src/Actions/Card/CardMoveAction.php index dcbf290..f802c7d 100644 --- a/src/Actions/Card/CardMoveAction.php +++ b/src/Actions/Card/CardMoveAction.php @@ -13,7 +13,8 @@ final class CardMoveAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardHydrateTrait; + use AuthenticateTrait; + use CardHydrateTrait; public function __construct(private readonly CardDto $card, string $token) { @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Card/CardSubscribeMembershipAction.php b/src/Actions/Card/CardSubscribeMembershipAction.php index fa76b25..e772a50 100644 --- a/src/Actions/Card/CardSubscribeMembershipAction.php +++ b/src/Actions/Card/CardSubscribeMembershipAction.php @@ -12,12 +12,13 @@ final class CardSubscribeMembershipAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardMembershipHydrateTrait; + use AuthenticateTrait; + use CardMembershipHydrateTrait; public function __construct( private readonly string $cardId, private readonly string $userId, - string $token + string $token, ) { $this->setToken($token); } diff --git a/src/Actions/Card/CardTimerAction.php b/src/Actions/Card/CardTimerAction.php index 63de237..9fb8f1c 100644 --- a/src/Actions/Card/CardTimerAction.php +++ b/src/Actions/Card/CardTimerAction.php @@ -11,11 +11,11 @@ use Planka\Bridge\Traits\AuthenticateTrait; use Planka\Bridge\Traits\CardHydrateTrait; use Planka\Bridge\Views\Dto\Card\CardDto; -use DateTimeImmutable; final class CardTimerAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardHydrateTrait; + use AuthenticateTrait; + use CardHydrateTrait; private bool $start; @@ -42,7 +42,7 @@ public function getOptions(): array // stop timer if (!$this->start) { - if ($this->card->stopwatch !== null) { + if (null !== $this->card->stopwatch) { $diff = time() - $this->card->stopwatch->startedAt->getTimestamp(); $total = $this->card->stopwatch->total + $diff; @@ -55,8 +55,8 @@ public function getOptions(): array return [ 'json' => [ 'stopwatch' => [ - "startedAt" => $startedAt, - "total" => $total, + 'startedAt' => $startedAt, + 'total' => $total, ], ], ]; @@ -68,9 +68,9 @@ private function tickingWatch(): StopWatchDto if ($this->card->stopwatch) { $diff = $this->card->stopwatch->total; - return new StopWatchDto((new DateTimeImmutable())->modify("-{$diff} seconds"), 0); + return new StopWatchDto((new \DateTimeImmutable())->modify("-{$diff} seconds"), 0); } - return new StopWatchDto(new DateTimeImmutable(), 0); + return new StopWatchDto(new \DateTimeImmutable(), 0); } } diff --git a/src/Actions/Card/CardUnsubscribeMembershipAction.php b/src/Actions/Card/CardUnsubscribeMembershipAction.php index 4165e3f..d7de0d6 100644 --- a/src/Actions/Card/CardUnsubscribeMembershipAction.php +++ b/src/Actions/Card/CardUnsubscribeMembershipAction.php @@ -12,12 +12,13 @@ final class CardUnsubscribeMembershipAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardMembershipHydrateTrait; + use AuthenticateTrait; + use CardMembershipHydrateTrait; public function __construct( private readonly string $cardId, private readonly string $userId, - string $token + string $token, ) { $this->setToken($token); } diff --git a/src/Actions/Card/CardUpdateAction.php b/src/Actions/Card/CardUpdateAction.php index 989dd56..04dd0f9 100644 --- a/src/Actions/Card/CardUpdateAction.php +++ b/src/Actions/Card/CardUpdateAction.php @@ -13,12 +13,13 @@ final class CardUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardHydrateTrait; + use AuthenticateTrait; + use CardHydrateTrait; public function __construct( private readonly CardDto $card, string $token, - private readonly ?int $spentSeconds = null + private readonly ?int $spentSeconds = null, ) { $this->setToken($token); } @@ -30,7 +31,7 @@ public function url(): string public function getOptions(): array { - if ($this->spentSeconds !== null) { + if (null !== $this->spentSeconds) { return [ 'json' => [ 'stopwatch' => [ @@ -51,7 +52,7 @@ public function getOptions(): array ], ]; - if ($this->card->stopwatch === null) { + if (null === $this->card->stopwatch) { $body['json']['stopwatch'] = null; } @@ -64,4 +65,4 @@ private function getTotalTime(): int return $time + $this->spentSeconds; } -} \ No newline at end of file +} diff --git a/src/Actions/Card/CardViewAction.php b/src/Actions/Card/CardViewAction.php index f947977..3cb354b 100644 --- a/src/Actions/Card/CardViewAction.php +++ b/src/Actions/Card/CardViewAction.php @@ -12,7 +12,8 @@ final class CardViewAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardHydrateTrait; + use AuthenticateTrait; + use CardHydrateTrait; public function __construct(private readonly string $cardId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/CardLabel/CardLabelCreateAction.php b/src/Actions/CardLabel/CardLabelCreateAction.php index ce09811..d425847 100644 --- a/src/Actions/CardLabel/CardLabelCreateAction.php +++ b/src/Actions/CardLabel/CardLabelCreateAction.php @@ -12,12 +12,13 @@ final class CardLabelCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardLabelHydrateTrait; + use AuthenticateTrait; + use CardLabelHydrateTrait; public function __construct( private readonly string $cardId, private readonly string $labelId, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/CardLabel/CardLabelDeleteAction.php b/src/Actions/CardLabel/CardLabelDeleteAction.php index d47f288..21ec9e6 100644 --- a/src/Actions/CardLabel/CardLabelDeleteAction.php +++ b/src/Actions/CardLabel/CardLabelDeleteAction.php @@ -12,12 +12,13 @@ final class CardLabelDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardLabelHydrateTrait; + use AuthenticateTrait; + use CardLabelHydrateTrait; public function __construct( private readonly string $cardId, private readonly string $labelId, - string $token + string $token, ) { $this->setToken($token); } @@ -31,4 +32,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/CardMembership/CardMembershipCreateAction.php b/src/Actions/CardMembership/CardMembershipCreateAction.php index 60c891e..709dda2 100644 --- a/src/Actions/CardMembership/CardMembershipCreateAction.php +++ b/src/Actions/CardMembership/CardMembershipCreateAction.php @@ -12,12 +12,13 @@ final class CardMembershipCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardMembershipHydrateTrait; + use AuthenticateTrait; + use CardMembershipHydrateTrait; public function __construct( private readonly string $cardId, private readonly string $userId, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/CardMembership/CardMembershipDeleteAction.php b/src/Actions/CardMembership/CardMembershipDeleteAction.php index 6772da5..e926361 100644 --- a/src/Actions/CardMembership/CardMembershipDeleteAction.php +++ b/src/Actions/CardMembership/CardMembershipDeleteAction.php @@ -12,12 +12,13 @@ final class CardMembershipDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardMembershipHydrateTrait; + use AuthenticateTrait; + use CardMembershipHydrateTrait; public function __construct( private readonly string $cardId, private readonly string $userId, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/CardTask/CardTaskCreateAction.php b/src/Actions/CardTask/CardTaskCreateAction.php index 1973b25..52476cb 100644 --- a/src/Actions/CardTask/CardTaskCreateAction.php +++ b/src/Actions/CardTask/CardTaskCreateAction.php @@ -12,7 +12,8 @@ final class CardTaskCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardTaskHydrateTrait; + use AuthenticateTrait; + use CardTaskHydrateTrait; public function __construct( private readonly string $cardId, @@ -37,4 +38,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/CardTask/CardTaskDeleteAction.php b/src/Actions/CardTask/CardTaskDeleteAction.php index a15122b..e1f38de 100644 --- a/src/Actions/CardTask/CardTaskDeleteAction.php +++ b/src/Actions/CardTask/CardTaskDeleteAction.php @@ -12,7 +12,8 @@ final class CardTaskDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardTaskHydrateTrait; + use AuthenticateTrait; + use CardTaskHydrateTrait; public function __construct(private readonly string $taskId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/CardTask/CardTaskUpdateAction.php b/src/Actions/CardTask/CardTaskUpdateAction.php index 12c5d29..0878a42 100644 --- a/src/Actions/CardTask/CardTaskUpdateAction.php +++ b/src/Actions/CardTask/CardTaskUpdateAction.php @@ -13,7 +13,8 @@ final class CardTaskUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CardTaskHydrateTrait; + use AuthenticateTrait; + use CardTaskHydrateTrait; public function __construct(private readonly CardTaskDto $task, string $token) { @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Comment/CommentCreateAction.php b/src/Actions/Comment/CommentCreateAction.php index e324943..5dcd96d 100644 --- a/src/Actions/Comment/CommentCreateAction.php +++ b/src/Actions/Comment/CommentCreateAction.php @@ -12,12 +12,13 @@ final class CommentCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CommentHydrateTrait; + use AuthenticateTrait; + use CommentHydrateTrait; public function __construct( private readonly string $cardId, private readonly string $text, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Comment/CommentDeleteAction.php b/src/Actions/Comment/CommentDeleteAction.php index da7ad7d..a2ea60a 100644 --- a/src/Actions/Comment/CommentDeleteAction.php +++ b/src/Actions/Comment/CommentDeleteAction.php @@ -12,7 +12,8 @@ final class CommentDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CommentHydrateTrait; + use AuthenticateTrait; + use CommentHydrateTrait; public function __construct(private readonly string $commentId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/Comment/CommentUpdateAction.php b/src/Actions/Comment/CommentUpdateAction.php index 7e6b093..ab81a9b 100644 --- a/src/Actions/Comment/CommentUpdateAction.php +++ b/src/Actions/Comment/CommentUpdateAction.php @@ -12,12 +12,13 @@ final class CommentUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, CommentHydrateTrait; + use AuthenticateTrait; + use CommentHydrateTrait; public function __construct( private readonly string $commentId, private readonly string $text, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Common/GetInfoAction.php b/src/Actions/Common/GetInfoAction.php index 49bad66..14d1cee 100644 --- a/src/Actions/Common/GetInfoAction.php +++ b/src/Actions/Common/GetInfoAction.php @@ -17,4 +17,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/Label/LabelCreateAction.php b/src/Actions/Label/LabelCreateAction.php index 39bf41f..8d16e46 100644 --- a/src/Actions/Label/LabelCreateAction.php +++ b/src/Actions/Label/LabelCreateAction.php @@ -13,14 +13,15 @@ final class LabelCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, LabelHydrateTrait; + use AuthenticateTrait; + use LabelHydrateTrait; public function __construct( private readonly string $boardId, private readonly string $name, private readonly LabelColorEnum $color, private readonly int $position, - string $token + string $token, ) { $this->setToken($token); } @@ -40,4 +41,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Label/LabelDeleteAction.php b/src/Actions/Label/LabelDeleteAction.php index 388f30c..960bb39 100644 --- a/src/Actions/Label/LabelDeleteAction.php +++ b/src/Actions/Label/LabelDeleteAction.php @@ -12,7 +12,8 @@ final class LabelDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, LabelHydrateTrait; + use AuthenticateTrait; + use LabelHydrateTrait; public function __construct(private readonly string $labelId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/Label/LabelUpdateAction.php b/src/Actions/Label/LabelUpdateAction.php index e2da1bf..9f8afd9 100644 --- a/src/Actions/Label/LabelUpdateAction.php +++ b/src/Actions/Label/LabelUpdateAction.php @@ -13,13 +13,14 @@ final class LabelUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, LabelHydrateTrait; + use AuthenticateTrait; + use LabelHydrateTrait; public function __construct( private readonly string $labelId, private readonly string $name, private readonly LabelColorEnum $color, - string $token + string $token, ) { $this->setToken($token); } @@ -38,4 +39,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Notification/NotificationListAction.php b/src/Actions/Notification/NotificationListAction.php index a8bf444..30aa58c 100644 --- a/src/Actions/Notification/NotificationListAction.php +++ b/src/Actions/Notification/NotificationListAction.php @@ -28,7 +28,7 @@ public function __construct(string $token) public function url(): string { - return "api/notifications"; + return 'api/notifications'; } public function getOptions(): array @@ -47,4 +47,4 @@ public function hydrate(ResponseInterface $response): NotificationListDto { return (new NotificationListDtoFactory())->create($response->toArray()); } -} \ No newline at end of file +} diff --git a/src/Actions/Notification/NotificationUpdateAction.php b/src/Actions/Notification/NotificationUpdateAction.php index d827dc3..95ad621 100644 --- a/src/Actions/Notification/NotificationUpdateAction.php +++ b/src/Actions/Notification/NotificationUpdateAction.php @@ -16,6 +16,7 @@ use Planka\Bridge\Contracts\Actions\ActionInterface; use Symfony\Contracts\HttpClient\ResponseInterface; use Planka\Bridge\Traits\AuthenticateTrait; + use function Fp\Collection\map; final class NotificationUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface @@ -25,7 +26,7 @@ final class NotificationUpdateAction implements ActionInterface, AuthenticateInt public function __construct( private readonly array $notifyIdList, private readonly bool $isRead, - string $token + string $token, ) { $this->setToken($token); } @@ -48,6 +49,7 @@ public function getOptions(): array /** * @return list + * * @throws ClientExceptionInterface * @throws DecodingExceptionInterface * @throws RedirectionExceptionInterface @@ -60,4 +62,4 @@ public function hydrate(ResponseInterface $response): array return map($data['items'] ?? [], fn(array $item) => (new NotificationItemDtoFactory())->create($item)); } -} \ No newline at end of file +} diff --git a/src/Actions/Notification/NotificationVewAction.php b/src/Actions/Notification/NotificationVewAction.php index b46749a..4ea72d1 100644 --- a/src/Actions/Notification/NotificationVewAction.php +++ b/src/Actions/Notification/NotificationVewAction.php @@ -12,7 +12,8 @@ final class NotificationVewAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, NotificationHydrateTrait; + use AuthenticateTrait; + use NotificationHydrateTrait; public function __construct(private readonly string $notifyId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/Project/ProjectCreateAction.php b/src/Actions/Project/ProjectCreateAction.php index 8ba5306..421f0a6 100644 --- a/src/Actions/Project/ProjectCreateAction.php +++ b/src/Actions/Project/ProjectCreateAction.php @@ -12,7 +12,8 @@ final class ProjectCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, ProjectHydrateTrait; + use AuthenticateTrait; + use ProjectHydrateTrait; public function __construct(private readonly string $name, string $token) { @@ -21,7 +22,7 @@ public function __construct(private readonly string $name, string $token) public function url(): string { - return "api/projects"; + return 'api/projects'; } public function getOptions(): array @@ -32,4 +33,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Project/ProjectDeleteAction.php b/src/Actions/Project/ProjectDeleteAction.php index de2b839..9d22b4e 100644 --- a/src/Actions/Project/ProjectDeleteAction.php +++ b/src/Actions/Project/ProjectDeleteAction.php @@ -12,7 +12,8 @@ final class ProjectDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, ProjectHydrateTrait; + use AuthenticateTrait; + use ProjectHydrateTrait; public function __construct(private readonly string $projectId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/Project/ProjectListAction.php b/src/Actions/Project/ProjectListAction.php index 3024ae5..d351127 100644 --- a/src/Actions/Project/ProjectListAction.php +++ b/src/Actions/Project/ProjectListAction.php @@ -1,6 +1,6 @@ getContent()); } -} \ No newline at end of file +} diff --git a/src/Actions/Project/ProjectUpdateAction.php b/src/Actions/Project/ProjectUpdateAction.php index dd8e9c5..bc7b712 100644 --- a/src/Actions/Project/ProjectUpdateAction.php +++ b/src/Actions/Project/ProjectUpdateAction.php @@ -15,7 +15,8 @@ final class ProjectUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, ProjectHydrateTrait; + use AuthenticateTrait; + use ProjectHydrateTrait; public function __construct(private readonly ProjectDto $project, string $token) { @@ -38,7 +39,7 @@ public function getOptions(): array ], ]; - if ($this->project?->background?->type === BackgroundTypeEnum::IMAGE) { + if (BackgroundTypeEnum::IMAGE === $this->project?->background?->type) { $this->validateBackgroundImage(); $body['json']['background'] = [ @@ -46,7 +47,7 @@ public function getOptions(): array ]; } - if ($this->project?->background?->type === BackgroundTypeEnum::GRADIENT) { + if (BackgroundTypeEnum::GRADIENT === $this->project?->background?->type) { $this->validateBackgroundGradient(); $body['json']['background'] = [ @@ -55,11 +56,11 @@ public function getOptions(): array ]; } - if ($this->project->background === null) { + if (null === $this->project->background) { $body['json']['background'] = null; } - if ($this->project?->backgroundImage === null) { + if (null === $this->project?->backgroundImage) { $body['json']['backgroundImage'] = null; } @@ -71,7 +72,7 @@ public function getOptions(): array */ private function validateBackgroundImage(): void { - if ($this->project->backgroundImage === null) { + if (null === $this->project->backgroundImage) { throw new ValidateException('Empty image data for backgroundImage parameter'); } } @@ -81,8 +82,8 @@ private function validateBackgroundImage(): void */ private function validateBackgroundGradient(): void { - if ($this->project->background->name === null) { + if (null === $this->project->background->name) { throw new ValidateException('Select gradient name by gradient background'); } } -} \ No newline at end of file +} diff --git a/src/Actions/Project/ProjectUpdateBackgroundImageAction.php b/src/Actions/Project/ProjectUpdateBackgroundImageAction.php index ef47787..4dee451 100644 --- a/src/Actions/Project/ProjectUpdateBackgroundImageAction.php +++ b/src/Actions/Project/ProjectUpdateBackgroundImageAction.php @@ -1,6 +1,6 @@ setToken($token); @@ -51,4 +53,4 @@ public function getOptions(): array 'body' => $formData->bodyToIterable(), ]; } -} \ No newline at end of file +} diff --git a/src/Actions/Project/ProjectViewAction.php b/src/Actions/Project/ProjectViewAction.php index 0120fcb..c3a994e 100644 --- a/src/Actions/Project/ProjectViewAction.php +++ b/src/Actions/Project/ProjectViewAction.php @@ -12,7 +12,8 @@ final class ProjectViewAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, ProjectHydrateTrait; + use AuthenticateTrait; + use ProjectHydrateTrait; public function __construct(private readonly string $projectId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/ProjectManager/ProjectManagerCreateAction.php b/src/Actions/ProjectManager/ProjectManagerCreateAction.php index f2bde65..8075195 100644 --- a/src/Actions/ProjectManager/ProjectManagerCreateAction.php +++ b/src/Actions/ProjectManager/ProjectManagerCreateAction.php @@ -12,12 +12,13 @@ final class ProjectManagerCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, ProjectManagerHydrateTrait; + use AuthenticateTrait; + use ProjectManagerHydrateTrait; public function __construct( private readonly string $projectId, private readonly string $userId, - string $token + string $token, ) { $this->setToken($token); } @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/ProjectManager/ProjectManagerDeleteAction.php b/src/Actions/ProjectManager/ProjectManagerDeleteAction.php index 5acdeb9..d536f7d 100644 --- a/src/Actions/ProjectManager/ProjectManagerDeleteAction.php +++ b/src/Actions/ProjectManager/ProjectManagerDeleteAction.php @@ -12,7 +12,8 @@ final class ProjectManagerDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, ProjectManagerHydrateTrait; + use AuthenticateTrait; + use ProjectManagerHydrateTrait; public function __construct(private readonly string $projectManagerId, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/User/UserCreateAction.php b/src/Actions/User/UserCreateAction.php index f293e34..808d073 100644 --- a/src/Actions/User/UserCreateAction.php +++ b/src/Actions/User/UserCreateAction.php @@ -12,7 +12,8 @@ final class UserCreateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; public function __construct( private readonly string $email, @@ -40,4 +41,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/User/UserDeleteAction.php b/src/Actions/User/UserDeleteAction.php index c244796..0949829 100644 --- a/src/Actions/User/UserDeleteAction.php +++ b/src/Actions/User/UserDeleteAction.php @@ -13,7 +13,8 @@ final class UserDeleteAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; public function __construct(private readonly UserDto $user, string $token) { @@ -31,4 +32,4 @@ public function getOptions(): array 'body' => [], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/User/UserListAction.php b/src/Actions/User/UserListAction.php index 2d511d0..abe04f4 100644 --- a/src/Actions/User/UserListAction.php +++ b/src/Actions/User/UserListAction.php @@ -12,7 +12,8 @@ final class UserListAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; public function __construct(string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Actions/User/UserUpdateAction.php b/src/Actions/User/UserUpdateAction.php index 07ca48d..bdc05f6 100644 --- a/src/Actions/User/UserUpdateAction.php +++ b/src/Actions/User/UserUpdateAction.php @@ -13,7 +13,8 @@ final class UserUpdateAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; public function __construct(private readonly UserDto $user, string $token) { @@ -35,4 +36,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/User/UserUpdateAvatarAction.php b/src/Actions/User/UserUpdateAvatarAction.php index 0985a53..66b0d48 100644 --- a/src/Actions/User/UserUpdateAvatarAction.php +++ b/src/Actions/User/UserUpdateAvatarAction.php @@ -16,7 +16,8 @@ final class UserUpdateAvatarAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; /** * @throws FileExistException @@ -24,7 +25,7 @@ final class UserUpdateAvatarAction implements ActionInterface, AuthenticateInter public function __construct( private readonly UserDto $user, private readonly string $file, - string $token + string $token, ) { $this->setToken($token); @@ -50,4 +51,4 @@ public function getOptions(): array 'body' => $formData->bodyToIterable(), ]; } -} \ No newline at end of file +} diff --git a/src/Actions/User/UserUpdateEmailAction.php b/src/Actions/User/UserUpdateEmailAction.php index f119c32..a7b91f6 100644 --- a/src/Actions/User/UserUpdateEmailAction.php +++ b/src/Actions/User/UserUpdateEmailAction.php @@ -13,7 +13,8 @@ final class UserUpdateEmailAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; public function __construct(private readonly UserDto $user, string $token) { diff --git a/src/Actions/User/UserUpdatePasswordAction.php b/src/Actions/User/UserUpdatePasswordAction.php index cfaf946..ea52882 100644 --- a/src/Actions/User/UserUpdatePasswordAction.php +++ b/src/Actions/User/UserUpdatePasswordAction.php @@ -12,13 +12,14 @@ final class UserUpdatePasswordAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; public function __construct( private readonly string $userId, private readonly string $current, private readonly string $new, - string $token + string $token, ) { $this->setToken($token); } @@ -37,4 +38,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/User/UserUpdateUsernameAction.php b/src/Actions/User/UserUpdateUsernameAction.php index 4466b94..f85eb47 100644 --- a/src/Actions/User/UserUpdateUsernameAction.php +++ b/src/Actions/User/UserUpdateUsernameAction.php @@ -13,7 +13,8 @@ final class UserUpdateUsernameAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; public function __construct(private readonly UserDto $user, string $token) { @@ -33,4 +34,4 @@ public function getOptions(): array ], ]; } -} \ No newline at end of file +} diff --git a/src/Actions/User/UserViewAction.php b/src/Actions/User/UserViewAction.php index ab40f91..53d2397 100644 --- a/src/Actions/User/UserViewAction.php +++ b/src/Actions/User/UserViewAction.php @@ -12,7 +12,8 @@ final class UserViewAction implements ActionInterface, AuthenticateInterface, ResponseResultInterface { - use AuthenticateTrait, UserHydrateTrait; + use AuthenticateTrait; + use UserHydrateTrait; public function __construct(private readonly string $id, string $token) { @@ -28,4 +29,4 @@ public function getOptions(): array { return []; } -} \ No newline at end of file +} diff --git a/src/Config.php b/src/Config.php index 4fc69bb..ddbfad7 100644 --- a/src/Config.php +++ b/src/Config.php @@ -13,8 +13,7 @@ public function __construct( private readonly string $password, private readonly string $baseUri, private readonly int $port, - ) { - } + ) {} public function getUser(): string { @@ -45,4 +44,4 @@ public function getPort(): int { return $this->port; } -} \ No newline at end of file +} diff --git a/src/Contracts/Actions/ActionInterface.php b/src/Contracts/Actions/ActionInterface.php index b5f1903..5271977 100644 --- a/src/Contracts/Actions/ActionInterface.php +++ b/src/Contracts/Actions/ActionInterface.php @@ -1,5 +1,7 @@ */ public function getOptions(): array; -} \ No newline at end of file +} diff --git a/src/Contracts/Actions/AuthenticateInterface.php b/src/Contracts/Actions/AuthenticateInterface.php index 137323a..6232176 100644 --- a/src/Contracts/Actions/AuthenticateInterface.php +++ b/src/Contracts/Actions/AuthenticateInterface.php @@ -1,8 +1,10 @@ client->post(new AttachmentCreateAction( cardId: $cardId, file: $file, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -39,7 +39,7 @@ public function updateName(string $attachmentId, string $name): AttachmentDto return $this->client->patch(new AttachmentUpdateAction( attachmentId: $attachmentId, name: $name, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -48,7 +48,7 @@ public function delete(string $attachmentId): AttachmentDto { return $this->client->delete(new AttachmentDeleteAction( attachmentId: $attachmentId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } -} \ No newline at end of file +} diff --git a/src/Controllers/Board.php b/src/Controllers/Board.php index 010c274..44c82e4 100644 --- a/src/Controllers/Board.php +++ b/src/Controllers/Board.php @@ -16,9 +16,8 @@ final class Board { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/projects/:projectId/boards' */ public function create(string $projectId, string $name, int $position): BoardDto @@ -27,7 +26,7 @@ public function create(string $projectId, string $name, int $position): BoardDto projectId: $projectId, name: $name, position: $position, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -43,7 +42,7 @@ public function update(string $boardId, string $name): BoardDto return $this->client->patch(new BoardUpdateAction( boardId: $boardId, name: $name, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -52,4 +51,4 @@ public function delete(string $boardId): BoardDto { return $this->client->delete(new BoardDeleteAction(boardId: $boardId, token: $this->config->getAuthToken())); } -} \ No newline at end of file +} diff --git a/src/Controllers/BoardList.php b/src/Controllers/BoardList.php index 6a213dc..1cdec23 100644 --- a/src/Controllers/BoardList.php +++ b/src/Controllers/BoardList.php @@ -15,9 +15,8 @@ final class BoardList { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/boards/:boardId/lists' */ public function create(string $boardId, string $name, int $position): BoardListDto @@ -26,7 +25,7 @@ public function create(string $boardId, string $name, int $position): BoardListD boardId: $boardId, name: $name, position: $position, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -36,7 +35,7 @@ public function update(string $listId, string $name): BoardListDto return $this->client->patch(new BoardListUpdateAction( listId: $listId, name: $name, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -45,4 +44,4 @@ public function delete(string $listId): BoardListDto { return $this->client->delete(new BoardListDeleteAction(listId: $listId, token: $this->config->getAuthToken())); } -} \ No newline at end of file +} diff --git a/src/Controllers/BoardMembership.php b/src/Controllers/BoardMembership.php index 9031550..4003dcd 100644 --- a/src/Controllers/BoardMembership.php +++ b/src/Controllers/BoardMembership.php @@ -16,9 +16,8 @@ final class BoardMembership { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/boards/:boardId/memberships' */ public function add(string $boardId, string $userId, BoardMembershipRoleEnum $role): BoardMembershipDto @@ -27,7 +26,7 @@ public function add(string $boardId, string $userId, BoardMembershipRoleEnum $ro boardId: $boardId, userId: $userId, role: $role, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -35,13 +34,13 @@ public function add(string $boardId, string $userId, BoardMembershipRoleEnum $ro public function update( string $membershipId, BoardMembershipRoleEnum $role, - bool $canComment = true + bool $canComment = true, ): BoardMembershipDto { return $this->client->patch(new BoardMembershipUpdateAction( membershipId: $membershipId, role: $role, token: $this->config->getAuthToken(), - canComment: $canComment + canComment: $canComment, )); } @@ -50,7 +49,7 @@ public function delete(string $membership): BoardMembershipDto { return $this->client->delete(new BoardMembershipDeleteAction( membership: $membership, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } -} \ No newline at end of file +} diff --git a/src/Controllers/Card.php b/src/Controllers/Card.php index 5052455..4130e91 100644 --- a/src/Controllers/Card.php +++ b/src/Controllers/Card.php @@ -22,9 +22,8 @@ final class Card { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/lists/:listId/cards' */ public function create(string $listId, string $name, int $position): CardDto @@ -33,7 +32,7 @@ public function create(string $listId, string $name, int $position): CardDto listId: $listId, name: $name, position: $position, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -48,7 +47,7 @@ public function update(CardDto $card): CardDto { return $this->client->patch(new CardUpdateAction( card: $card, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -57,7 +56,7 @@ public function clearTime(CardDto $card): CardDto { return $this->client->patch(new CardClearDueDateAction( card: $card, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -66,7 +65,7 @@ public function moveCard(CardDto $card): CardDto { return $this->client->patch(new CardMoveAction( card: $card, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -76,7 +75,7 @@ public function addSpentTime(CardDto $card, int $seconds): CardDto return $this->client->patch(new CardUpdateAction( card: $card, token: $this->config->getAuthToken(), - spentSeconds: $seconds + spentSeconds: $seconds, )); } @@ -86,7 +85,7 @@ public function triggerTimer(CardDto $card, bool $start): CardDto return $this->client->patch(new CardTimerAction( card: $card, token: $this->config->getAuthToken(), - start: $start + start: $start, )); } @@ -102,7 +101,7 @@ public function subscribe(string $cardId, string $userId): CardMembershipDto return $this->client->post(new CardSubscribeMembershipAction( cardId: $cardId, userId: $userId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -112,7 +111,7 @@ public function unsubscribe(string $cardId, string $userId): CardMembershipDto return $this->client->delete(new CardUnsubscribeMembershipAction( cardId: $cardId, userId: $userId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } } diff --git a/src/Controllers/CardAction.php b/src/Controllers/CardAction.php index 74c43b1..babdafc 100644 --- a/src/Controllers/CardAction.php +++ b/src/Controllers/CardAction.php @@ -13,13 +13,12 @@ final class CardAction { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'GET /api/cards/:cardId/actions' */ public function getActions(string $cardId): CardActionListDto { return $this->client->get(new CardActionViewAction(cardId: $cardId, token: $this->config->getAuthToken())); } -} \ No newline at end of file +} diff --git a/src/Controllers/CardLabel.php b/src/Controllers/CardLabel.php index f2991f6..986cf58 100644 --- a/src/Controllers/CardLabel.php +++ b/src/Controllers/CardLabel.php @@ -14,9 +14,8 @@ final class CardLabel { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/cards/:cardId/labels' */ public function add(string $cardId, string $labelId): CardLabelDto @@ -24,7 +23,7 @@ public function add(string $cardId, string $labelId): CardLabelDto return $this->client->post(new CardLabelCreateAction( cardId: $cardId, labelId: $labelId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -34,7 +33,7 @@ public function remove(string $cardId, string $labelId): CardLabelDto return $this->client->delete(new CardLabelDeleteAction( cardId: $cardId, labelId: $labelId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } -} \ No newline at end of file +} diff --git a/src/Controllers/CardMembership.php b/src/Controllers/CardMembership.php index c288287..fb574a3 100644 --- a/src/Controllers/CardMembership.php +++ b/src/Controllers/CardMembership.php @@ -14,9 +14,8 @@ final class CardMembership { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/cards/:cardId/memberships' */ public function add(string $cardId, string $userId): CardMembershipDto @@ -24,7 +23,7 @@ public function add(string $cardId, string $userId): CardMembershipDto return $this->client->post(new CardMembershipCreateAction( cardId: $cardId, userId: $userId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -34,7 +33,7 @@ public function remove(string $cardId, string $userId): CardMembershipDto return $this->client->delete(new CardMembershipDeleteAction( cardId: $cardId, userId: $userId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } -} \ No newline at end of file +} diff --git a/src/Controllers/CardTask.php b/src/Controllers/CardTask.php index 15012f0..fe9841e 100644 --- a/src/Controllers/CardTask.php +++ b/src/Controllers/CardTask.php @@ -15,9 +15,8 @@ final class CardTask { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/cards/:cardId/tasks' */ public function create(string $cardId, string $name, int $position): CardTaskDto @@ -26,7 +25,7 @@ public function create(string $cardId, string $name, int $position): CardTaskDto cardId: $cardId, name: $name, position: $position, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -35,7 +34,7 @@ public function update(CardTaskDto $task): CardTaskDto { return $this->client->patch(new CardTaskUpdateAction( task: $task, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -44,4 +43,4 @@ public function delete(string $taskId): CardTaskDto { return $this->client->delete(new CardTaskDeleteAction(taskId: $taskId, token: $this->config->getAuthToken())); } -} \ No newline at end of file +} diff --git a/src/Controllers/Comment.php b/src/Controllers/Comment.php index d6a9314..b14b8d2 100644 --- a/src/Controllers/Comment.php +++ b/src/Controllers/Comment.php @@ -15,9 +15,8 @@ final class Comment { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/cards/:cardId/comment-actions' */ public function add(string $cardId, string $text): CommentDto @@ -25,7 +24,7 @@ public function add(string $cardId, string $text): CommentDto return $this->client->post(new CommentCreateAction( cardId: $cardId, text: $text, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -35,7 +34,7 @@ public function update(string $commentId, string $text): CommentDto return $this->client->patch(new CommentUpdateAction( commentId: $commentId, text: $text, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -44,7 +43,7 @@ public function remove(string $commentId): CommentDto { return $this->client->delete(new CommentDeleteAction( commentId: $commentId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } -} \ No newline at end of file +} diff --git a/src/Controllers/Label.php b/src/Controllers/Label.php index 4d5b15c..72969c1 100644 --- a/src/Controllers/Label.php +++ b/src/Controllers/Label.php @@ -16,9 +16,8 @@ final class Label { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'POST /api/boards/:boardId/labels' */ public function create(string $boardId, string $name, LabelColorEnum $color, int $position): LabelDto @@ -28,7 +27,7 @@ public function create(string $boardId, string $name, LabelColorEnum $color, int name: $name, color: $color, position: $position, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -39,7 +38,7 @@ public function update(string $labelId, string $name, LabelColorEnum $color): La labelId: $labelId, name: $name, color: $color, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -48,4 +47,4 @@ public function delete(string $labelId): LabelDto { return $this->client->delete(new LabelDeleteAction(labelId: $labelId, token: $this->config->getAuthToken())); } -} \ No newline at end of file +} diff --git a/src/Controllers/Notification.php b/src/Controllers/Notification.php index af4f7a2..fe0d78c 100644 --- a/src/Controllers/Notification.php +++ b/src/Controllers/Notification.php @@ -16,9 +16,8 @@ final class Notification { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** 'GET /api/notifications' */ public function list(): NotificationListDto @@ -27,18 +26,19 @@ public function list(): NotificationListDto } /** - * 'GET /api/notifications/:id' + * 'GET /api/notifications/:id'. */ public function getOne(string $notifyId): NotificationItemDto { return $this->client->get(new NotificationVewAction( notifyId: $notifyId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } /** - * 'PATCH /api/notifications/:ids' + * 'PATCH /api/notifications/:ids'. + * * @return list */ public function markIsRead(array $notifyIdList): array @@ -46,12 +46,13 @@ public function markIsRead(array $notifyIdList): array return $this->client->patch(new NotificationUpdateAction( notifyIdList: $notifyIdList, isRead: true, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } /** - * 'PATCH /api/notifications/:ids' + * 'PATCH /api/notifications/:ids'. + * * @return list */ public function markIsNotRead(array $notifyIdList): array @@ -59,7 +60,7 @@ public function markIsNotRead(array $notifyIdList): array return $this->client->patch(new NotificationUpdateAction( notifyIdList: $notifyIdList, isRead: false, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } -} \ No newline at end of file +} diff --git a/src/Controllers/Project.php b/src/Controllers/Project.php index 3a6133b..4158254 100644 --- a/src/Controllers/Project.php +++ b/src/Controllers/Project.php @@ -20,13 +20,11 @@ final class Project { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** - * 'GET /api/projects' - * @return ProjectListDto + * 'GET /api/projects'. */ public function list(): ProjectListDto { @@ -59,12 +57,13 @@ public function delete(string $projectId): ProjectDto { return $this->client->delete(new ProjectDeleteAction( projectId: $projectId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } /** - * 'POST /api/projects/:id/background-image' + * 'POST /api/projects/:id/background-image'. + * * @throws FileExistException */ public function updateBackgroundImage(string $projectId, string $file): ProjectDto @@ -72,7 +71,7 @@ public function updateBackgroundImage(string $projectId, string $file): ProjectD return $this->client->post(new ProjectUpdateBackgroundImageAction( projectId: $projectId, file: $file, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } -} \ No newline at end of file +} diff --git a/src/Controllers/ProjectManager.php b/src/Controllers/ProjectManager.php index 65890ac..e8133e2 100644 --- a/src/Controllers/ProjectManager.php +++ b/src/Controllers/ProjectManager.php @@ -17,12 +17,12 @@ final class ProjectManager { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** - * 'POST /api/projects/:projectId/managers' + * 'POST /api/projects/:projectId/managers'. + * * @throws ResponseException|ValidateException */ public function add(string $projectId, string $userId): ProjectManagerDto @@ -31,10 +31,10 @@ public function add(string $projectId, string $userId): ProjectManagerDto return $this->client->post(new ProjectManagerCreateAction( projectId: $projectId, userId: $userId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } catch (ClientException $exception) { - if ($exception->getCode() === 409) { + if (409 === $exception->getCode()) { throw new ValidateException('User already joined to project managers'); } @@ -47,7 +47,7 @@ public function remove(string $managerId): ProjectManagerDto { return $this->client->delete(new ProjectManagerDeleteAction( projectManagerId: $managerId, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } -} \ No newline at end of file +} diff --git a/src/Controllers/User.php b/src/Controllers/User.php index d20bdd0..d5260dd 100644 --- a/src/Controllers/User.php +++ b/src/Controllers/User.php @@ -22,12 +22,12 @@ final class User { public function __construct( private readonly Config $config, - private readonly Client $client - ) { - } + private readonly Client $client, + ) {} /** - * 'GET /api/users' + * 'GET /api/users'. + * * @return UserDto[] */ public function list(): array @@ -43,7 +43,7 @@ public function create(string $email, string $name, string $password, string $us name: $name, password: $password, username: $username, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -72,7 +72,7 @@ public function updatePassword(string $id, string $current, string $new): UserDt userId: $id, current: $current, new: $new, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -83,7 +83,8 @@ public function updateUsername(UserDto $dto): UserDto } /** - * 'POST /api/users/:id/avatar' + * 'POST /api/users/:id/avatar'. + * * @throws FileExistException */ public function updateAvatar(UserDto $dto, string $file): UserDto @@ -91,7 +92,7 @@ public function updateAvatar(UserDto $dto, string $file): UserDto return $this->client->post(new UserUpdateAvatarAction( user: $dto, file: $file, - token: $this->config->getAuthToken() + token: $this->config->getAuthToken(), )); } @@ -100,4 +101,4 @@ public function delete(UserDto $dto): UserDto { return $this->client->delete(new UserDeleteAction(user: $dto, token: $this->config->getAuthToken())); } -} \ No newline at end of file +} diff --git a/src/Enum/BackgroundGradientEnum.php b/src/Enum/BackgroundGradientEnum.php index ef6c890..43275f0 100644 --- a/src/Enum/BackgroundGradientEnum.php +++ b/src/Enum/BackgroundGradientEnum.php @@ -1,5 +1,7 @@ config->getBaseUri(), $this->config->getPort()); } @@ -78,7 +92,8 @@ public function __construct( } /** - * 'POST /api/access-tokens' + * 'POST /api/access-tokens'. + * * @throws AuthenticateException */ public function authenticate(): bool @@ -97,7 +112,8 @@ public function authenticate(): bool } /** - * 'DELETE /api/access-tokens/me' + * 'DELETE /api/access-tokens/me'. + * * @throws AuthenticateException|LogoutException */ public function logout(): void @@ -106,7 +122,7 @@ public function logout(): void $this->config->setAuthToken(null); - if ($response->getStatusCode() !== 200) { + if (200 !== $response->getStatusCode()) { throw new LogoutException($response->getContent()); } } @@ -116,4 +132,4 @@ public function getInfo(): ResponseInterface { return $this->client->get(new GetInfoAction()); } -} \ No newline at end of file +} diff --git a/src/Traits/AttachmentHydrateTrait.php b/src/Traits/AttachmentHydrateTrait.php index 74b7cb5..5e635d4 100644 --- a/src/Traits/AttachmentHydrateTrait.php +++ b/src/Traits/AttachmentHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): AttachmentDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/AuthenticateTrait.php b/src/Traits/AuthenticateTrait.php index 07b7b7b..e6b624a 100644 --- a/src/Traits/AuthenticateTrait.php +++ b/src/Traits/AuthenticateTrait.php @@ -17,4 +17,4 @@ public function setToken(string $token): void { $this->token = $token; } -} \ No newline at end of file +} diff --git a/src/Traits/BoardListHydrateTrait.php b/src/Traits/BoardListHydrateTrait.php index 0a1d6be..f124a86 100644 --- a/src/Traits/BoardListHydrateTrait.php +++ b/src/Traits/BoardListHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): BoardListDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/BoardMembershipHydrateTrait.php b/src/Traits/BoardMembershipHydrateTrait.php index edf5f66..cc687c2 100644 --- a/src/Traits/BoardMembershipHydrateTrait.php +++ b/src/Traits/BoardMembershipHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): BoardMembershipDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/CardLabelHydrateTrait.php b/src/Traits/CardLabelHydrateTrait.php index 19bb0e7..5298064 100644 --- a/src/Traits/CardLabelHydrateTrait.php +++ b/src/Traits/CardLabelHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): CardLabelDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/CardMembershipHydrateTrait.php b/src/Traits/CardMembershipHydrateTrait.php index ca818a0..373bf32 100644 --- a/src/Traits/CardMembershipHydrateTrait.php +++ b/src/Traits/CardMembershipHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): CardMembershipDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/CardTaskHydrateTrait.php b/src/Traits/CardTaskHydrateTrait.php index 3da14f7..285863b 100644 --- a/src/Traits/CardTaskHydrateTrait.php +++ b/src/Traits/CardTaskHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): CardTaskDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/CommentHydrateTrait.php b/src/Traits/CommentHydrateTrait.php index 1680a8d..d34a1ca 100644 --- a/src/Traits/CommentHydrateTrait.php +++ b/src/Traits/CommentHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): CommentDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/DateConverterTrait.php b/src/Traits/DateConverterTrait.php index 0ce1d92..e97d41b 100644 --- a/src/Traits/DateConverterTrait.php +++ b/src/Traits/DateConverterTrait.php @@ -4,17 +4,14 @@ namespace Planka\Bridge\Traits; -use DateTimeImmutable; -use DateTimeInterface; - trait DateConverterTrait { - final public function convertToDateTime(?string $date): ?DateTimeImmutable + final public function convertToDateTime(?string $date): ?\DateTimeImmutable { - if ($date === null) { + if (null === $date) { return null; } - return DateTimeImmutable::createFromFormat(DateTimeInterface::RFC3339_EXTENDED, $date); + return \DateTimeImmutable::createFromFormat(\DateTimeInterface::RFC3339_EXTENDED, $date); } -} \ No newline at end of file +} diff --git a/src/Traits/LabelHydrateTrait.php b/src/Traits/LabelHydrateTrait.php index 1cbf769..b6dd40e 100644 --- a/src/Traits/LabelHydrateTrait.php +++ b/src/Traits/LabelHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): LabelDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/NotificationHydrateTrait.php b/src/Traits/NotificationHydrateTrait.php index 2b95098..f26de73 100644 --- a/src/Traits/NotificationHydrateTrait.php +++ b/src/Traits/NotificationHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): NotificationItemDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/ProjectHydrateTrait.php b/src/Traits/ProjectHydrateTrait.php index 8ef5cfe..983fa05 100644 --- a/src/Traits/ProjectHydrateTrait.php +++ b/src/Traits/ProjectHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): ProjectDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/ProjectManagerHydrateTrait.php b/src/Traits/ProjectManagerHydrateTrait.php index 55cb138..e5586d6 100644 --- a/src/Traits/ProjectManagerHydrateTrait.php +++ b/src/Traits/ProjectManagerHydrateTrait.php @@ -34,4 +34,4 @@ final public function hydrate(ResponseInterface $response): ProjectManagerDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/Traits/UserHydrateTrait.php b/src/Traits/UserHydrateTrait.php index b7a4737..687cca1 100644 --- a/src/Traits/UserHydrateTrait.php +++ b/src/Traits/UserHydrateTrait.php @@ -13,12 +13,14 @@ use Symfony\Contracts\HttpClient\ResponseInterface; use Planka\Bridge\Exceptions\ResponseException; use Planka\Bridge\Views\Dto\User\UserDto; + use function Fp\Collection\map; trait UserHydrateTrait { /** * @return list|UserDto + * * @throws ClientExceptionInterface * @throws DecodingExceptionInterface * @throws RedirectionExceptionInterface @@ -40,4 +42,4 @@ final public function hydrate(ResponseInterface $response): array|UserDto throw new ResponseException($response->getContent()); } -} \ No newline at end of file +} diff --git a/src/TransportClients/Client.php b/src/TransportClients/Client.php index c267c85..2865c52 100644 --- a/src/TransportClients/Client.php +++ b/src/TransportClients/Client.php @@ -20,20 +20,20 @@ class Client public function __construct( private readonly string $baseUri, private readonly int $port, - ?HttpClientInterface $client = null + ?HttpClientInterface $client = null, ) { $this->client = $client ?? HttpClient::create(); } /** - * check throw to auth, and return authNotAuth exception + * check throw to auth, and return authNotAuth exception. */ public function get(ActionInterface $action): mixed { $response = $this->client->request( method: 'GET', url: sprintf(self::URI_TEMPLATE, $this->baseUri, $this->port, $action->url()), - options: $this->compileOptions($action) + options: $this->compileOptions($action), ); return $this->getResult($action, $response); @@ -44,7 +44,7 @@ public function post(ActionInterface $action): mixed $response = $this->client->request( method: 'POST', url: sprintf(self::URI_TEMPLATE, $this->baseUri, $this->port, $action->url()), - options: $this->compileOptions($action) + options: $this->compileOptions($action), ); return $this->getResult($action, $response); @@ -55,7 +55,7 @@ public function patch(ActionInterface $action): mixed $response = $this->client->request( method: 'PATCH', url: sprintf(self::URI_TEMPLATE, $this->baseUri, $this->port, $action->url()), - options: $this->compileOptions($action) + options: $this->compileOptions($action), ); return $this->getResult($action, $response); @@ -66,17 +66,12 @@ public function delete(ActionInterface $action): mixed $response = $this->client->request( method: 'DELETE', url: sprintf(self::URI_TEMPLATE, $this->baseUri, $this->port, $action->url()), - options: $this->compileOptions($action) + options: $this->compileOptions($action), ); return $this->getResult($action, $response); } - /** - * @param ActionInterface $action - * @param ResponseInterface $response - * @return mixed - */ private function getResult(ActionInterface $action, ResponseInterface $response): mixed { if ($action instanceof ResponseResultInterface) { @@ -96,4 +91,4 @@ private function compileOptions(ActionInterface $action): array return $options; } -} \ No newline at end of file +} diff --git a/src/Views/Dto/Attachment/AttachmentDto.php b/src/Views/Dto/Attachment/AttachmentDto.php index 694a4b9..fb76a0c 100644 --- a/src/Views/Dto/Attachment/AttachmentDto.php +++ b/src/Views/Dto/Attachment/AttachmentDto.php @@ -5,7 +5,6 @@ namespace Planka\Bridge\Views\Dto\Attachment; use Planka\Bridge\Views\Dto\Image\ImageDto; -use DateTimeImmutable; class AttachmentDto { @@ -15,10 +14,9 @@ public function __construct( public readonly string $cardId, public readonly string $url, public readonly string $creatorUserId, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt = null, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt = null, public readonly ?string $coverUrl = null, - public readonly ?ImageDto $image = null - ) { - } -} \ No newline at end of file + public readonly ?ImageDto $image = null, + ) {} +} diff --git a/src/Views/Dto/Background/BackgroundDto.php b/src/Views/Dto/Background/BackgroundDto.php index b6f6382..6dd3aa7 100644 --- a/src/Views/Dto/Background/BackgroundDto.php +++ b/src/Views/Dto/Background/BackgroundDto.php @@ -13,6 +13,5 @@ class BackgroundDto implements OutputDtoInterface public function __construct( public BackgroundTypeEnum $type, public ?BackgroundGradientEnum $name, - ) { - } -} \ No newline at end of file + ) {} +} diff --git a/src/Views/Dto/Background/BackgroundImageDto.php b/src/Views/Dto/Background/BackgroundImageDto.php index 69036e3..86946c7 100644 --- a/src/Views/Dto/Background/BackgroundImageDto.php +++ b/src/Views/Dto/Background/BackgroundImageDto.php @@ -10,7 +10,6 @@ class BackgroundImageDto implements OutputDtoInterface { public function __construct( public readonly string $url, - public readonly string $coverUrl - ) { - } -} \ No newline at end of file + public readonly string $coverUrl, + ) {} +} diff --git a/src/Views/Dto/Board/BoardDto.php b/src/Views/Dto/Board/BoardDto.php index 9358b40..cf20ec2 100644 --- a/src/Views/Dto/Board/BoardDto.php +++ b/src/Views/Dto/Board/BoardDto.php @@ -10,7 +10,6 @@ class BoardDto implements OutputDtoInterface { public function __construct( public readonly ?BoardItemDto $item, - public readonly ?BoardIncludedDto $included - ) { - } -} \ No newline at end of file + public readonly ?BoardIncludedDto $included, + ) {} +} diff --git a/src/Views/Dto/Board/BoardIncludedDto.php b/src/Views/Dto/Board/BoardIncludedDto.php index 8b53e7f..65ad6f3 100644 --- a/src/Views/Dto/Board/BoardIncludedDto.php +++ b/src/Views/Dto/Board/BoardIncludedDto.php @@ -17,16 +17,16 @@ final class BoardIncludedDto { /** - * @param list $users + * @param list $users * @param list $boardMemberships - * @param list $labels - * @param list $lists - * @param list $cards - * @param list $cardMemberships - * @param list $cardLabels - * @param list $tasks - * @param list $attachments - * @param list $projects + * @param list $labels + * @param list $lists + * @param list $cards + * @param list $cardMemberships + * @param list $cardLabels + * @param list $tasks + * @param list $attachments + * @param list $projects */ public function __construct( public array $users, @@ -39,6 +39,5 @@ public function __construct( public array $tasks, public array $attachments, public array $projects, - ) { - } -} \ No newline at end of file + ) {} +} diff --git a/src/Views/Dto/Board/BoardItemDto.php b/src/Views/Dto/Board/BoardItemDto.php index 3c3368f..cfb48a9 100644 --- a/src/Views/Dto/Board/BoardItemDto.php +++ b/src/Views/Dto/Board/BoardItemDto.php @@ -5,7 +5,6 @@ namespace Planka\Bridge\Views\Dto\Board; use Planka\Bridge\Contracts\Dto\OutputDtoInterface; -use DateTimeImmutable; final class BoardItemDto implements OutputDtoInterface { @@ -14,8 +13,7 @@ public function __construct( public readonly ?string $projectId, public readonly ?int $position, public readonly ?string $name, - public readonly ?DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt = null, - ) { - } -} \ No newline at end of file + public readonly ?\DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt = null, + ) {} +} diff --git a/src/Views/Dto/Board/BoardListDto.php b/src/Views/Dto/Board/BoardListDto.php index 04f3baf..15e985c 100644 --- a/src/Views/Dto/Board/BoardListDto.php +++ b/src/Views/Dto/Board/BoardListDto.php @@ -4,17 +4,14 @@ namespace Planka\Bridge\Views\Dto\Board; -use DateTimeImmutable; - class BoardListDto { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public readonly int $position, public readonly string $name, public readonly string $boardId, - ) { - } -} \ No newline at end of file + ) {} +} diff --git a/src/Views/Dto/Board/BoardMembershipDto.php b/src/Views/Dto/Board/BoardMembershipDto.php index 63cfaee..9dee3d6 100644 --- a/src/Views/Dto/Board/BoardMembershipDto.php +++ b/src/Views/Dto/Board/BoardMembershipDto.php @@ -6,18 +6,16 @@ use Planka\Bridge\Contracts\Dto\OutputDtoInterface; use Planka\Bridge\Enum\BoardMembershipRoleEnum; -use DateTimeImmutable; final class BoardMembershipDto implements OutputDtoInterface { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public string $userId, public bool $canComment, public BoardMembershipRoleEnum $role, public string $boardId, - ) { - } -} \ No newline at end of file + ) {} +} diff --git a/src/Views/Dto/Card/CardActionItemDto.php b/src/Views/Dto/Card/CardActionItemDto.php index 2dcc204..8ded0a4 100644 --- a/src/Views/Dto/Card/CardActionItemDto.php +++ b/src/Views/Dto/Card/CardActionItemDto.php @@ -5,18 +5,16 @@ namespace Planka\Bridge\Views\Dto\Card; use Planka\Bridge\Enum\CommentTypeEnum; -use DateTimeImmutable; class CardActionItemDto { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public readonly CommentTypeEnum $type, public readonly string $dataText, public readonly string $cardId, - public readonly string $userId - ) { - } -} \ No newline at end of file + public readonly string $userId, + ) {} +} diff --git a/src/Views/Dto/Card/CardActionListDto.php b/src/Views/Dto/Card/CardActionListDto.php index be7923a..729d333 100644 --- a/src/Views/Dto/Card/CardActionListDto.php +++ b/src/Views/Dto/Card/CardActionListDto.php @@ -8,7 +8,6 @@ class CardActionListDto { public function __construct( public readonly array $items, - public readonly array $included - ) { - } -} \ No newline at end of file + public readonly array $included, + ) {} +} diff --git a/src/Views/Dto/Card/CardDto.php b/src/Views/Dto/Card/CardDto.php index 334af2a..1aae81a 100644 --- a/src/Views/Dto/Card/CardDto.php +++ b/src/Views/Dto/Card/CardDto.php @@ -5,18 +5,17 @@ namespace Planka\Bridge\Views\Dto\Card; use Planka\Bridge\Contracts\Dto\OutputDtoInterface; -use DateTimeImmutable; class CardDto implements OutputDtoInterface { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public int $position, public string $name, public ?string $description, - public ?DateTimeImmutable $dueDate, + public ?\DateTimeImmutable $dueDate, public readonly ?bool $isDueDateCompleted, public ?StopWatchDto $stopwatch, public string $boardId, @@ -24,7 +23,6 @@ public function __construct( public string $creatorUserId, public ?string $coverAttachmentId, public readonly bool $isSubscribed, - public readonly CardIncludedDto $included - ) { - } + public readonly CardIncludedDto $included, + ) {} } diff --git a/src/Views/Dto/Card/CardIncludedDto.php b/src/Views/Dto/Card/CardIncludedDto.php index a49a09e..838d793 100644 --- a/src/Views/Dto/Card/CardIncludedDto.php +++ b/src/Views/Dto/Card/CardIncludedDto.php @@ -9,16 +9,15 @@ class CardIncludedDto { /** - * @param list $cardMemberships - * @param list $cardLabels - * @param list $tasks - * @param list $attachments + * @param list $cardMemberships + * @param list $cardLabels + * @param list $tasks + * @param list $attachments */ public function __construct( public array $cardMemberships, public array $cardLabels, public array $tasks, - public array $attachments - ) { - } + public array $attachments, + ) {} } diff --git a/src/Views/Dto/Card/CardLabelDto.php b/src/Views/Dto/Card/CardLabelDto.php index ebf44df..b1ead4b 100644 --- a/src/Views/Dto/Card/CardLabelDto.php +++ b/src/Views/Dto/Card/CardLabelDto.php @@ -5,16 +5,14 @@ namespace Planka\Bridge\Views\Dto\Card; use Planka\Bridge\Contracts\Dto\OutputDtoInterface; -use DateTimeImmutable; class CardLabelDto implements OutputDtoInterface { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public readonly string $cardId, - public ?string $labelId - ) { - } -} \ No newline at end of file + public ?string $labelId, + ) {} +} diff --git a/src/Views/Dto/Card/CardMembershipDto.php b/src/Views/Dto/Card/CardMembershipDto.php index 8e8b8fe..3561c01 100644 --- a/src/Views/Dto/Card/CardMembershipDto.php +++ b/src/Views/Dto/Card/CardMembershipDto.php @@ -5,16 +5,14 @@ namespace Planka\Bridge\Views\Dto\Card; use Planka\Bridge\Contracts\Dto\OutputDtoInterface; -use DateTimeImmutable; class CardMembershipDto implements OutputDtoInterface { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public readonly string $cardId, - public readonly string $userId - ) { - } -} \ No newline at end of file + public readonly string $userId, + ) {} +} diff --git a/src/Views/Dto/Card/CardTaskDto.php b/src/Views/Dto/Card/CardTaskDto.php index 6d2f955..f99738e 100644 --- a/src/Views/Dto/Card/CardTaskDto.php +++ b/src/Views/Dto/Card/CardTaskDto.php @@ -5,18 +5,16 @@ namespace Planka\Bridge\Views\Dto\Card; use Planka\Bridge\Contracts\Dto\OutputDtoInterface; -use DateTimeImmutable; class CardTaskDto implements OutputDtoInterface { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public int $position, public string $name, public bool $isCompleted, - public string $cardId - ) { - } -} \ No newline at end of file + public string $cardId, + ) {} +} diff --git a/src/Views/Dto/Card/StopWatchDto.php b/src/Views/Dto/Card/StopWatchDto.php index 7ed0f4f..b3eafa0 100644 --- a/src/Views/Dto/Card/StopWatchDto.php +++ b/src/Views/Dto/Card/StopWatchDto.php @@ -4,13 +4,10 @@ namespace Planka\Bridge\Views\Dto\Card; -use DateTimeImmutable; - class StopWatchDto { public function __construct( - public ?DateTimeImmutable $startedAt, - public int $total - ) { - } -} \ No newline at end of file + public ?\DateTimeImmutable $startedAt, + public int $total, + ) {} +} diff --git a/src/Views/Dto/Comment/CommentDto.php b/src/Views/Dto/Comment/CommentDto.php index 109aded..03e590f 100644 --- a/src/Views/Dto/Comment/CommentDto.php +++ b/src/Views/Dto/Comment/CommentDto.php @@ -5,18 +5,16 @@ namespace Planka\Bridge\Views\Dto\Comment; use Planka\Bridge\Enum\CommentTypeEnum; -use DateTimeImmutable; class CommentDto { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public readonly string $cardId, public readonly string $userId, public readonly CommentTypeEnum $type, - public string $dataText - ) { - } -} \ No newline at end of file + public string $dataText, + ) {} +} diff --git a/src/Views/Dto/Image/ImageDto.php b/src/Views/Dto/Image/ImageDto.php index d93a509..7ab7ab5 100644 --- a/src/Views/Dto/Image/ImageDto.php +++ b/src/Views/Dto/Image/ImageDto.php @@ -8,7 +8,6 @@ class ImageDto { public function __construct( public readonly int $height, - public readonly int $width - ) { - } -} \ No newline at end of file + public readonly int $width, + ) {} +} diff --git a/src/Views/Dto/Label/LabelDto.php b/src/Views/Dto/Label/LabelDto.php index a4f45e6..79cc83b 100644 --- a/src/Views/Dto/Label/LabelDto.php +++ b/src/Views/Dto/Label/LabelDto.php @@ -6,18 +6,16 @@ use Planka\Bridge\Contracts\Dto\OutputDtoInterface; use Planka\Bridge\Enum\LabelColorEnum; -use DateTimeImmutable; class LabelDto implements OutputDtoInterface { public function __construct( public readonly string $id, public readonly string $boardId, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public int $position, public string $name, public ?LabelColorEnum $color, - ) { - } -} \ No newline at end of file + ) {} +} diff --git a/src/Views/Dto/List/ListDto.php b/src/Views/Dto/List/ListDto.php index 4d7468b..ea1517b 100644 --- a/src/Views/Dto/List/ListDto.php +++ b/src/Views/Dto/List/ListDto.php @@ -4,17 +4,14 @@ namespace Planka\Bridge\Views\Dto\List; -use DateTimeImmutable; - class ListDto { public function __construct( public readonly string $id, public readonly string $boardId, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public int $position, public string $name, - ) { - } -} \ No newline at end of file + ) {} +} diff --git a/src/Views/Dto/Notification/NotificationIncludedDto.php b/src/Views/Dto/Notification/NotificationIncludedDto.php index 4dd1bf9..a90dab5 100644 --- a/src/Views/Dto/Notification/NotificationIncludedDto.php +++ b/src/Views/Dto/Notification/NotificationIncludedDto.php @@ -9,7 +9,6 @@ class NotificationIncludedDto public function __construct( public readonly array $users, public readonly array $cards, - public readonly array $actions - ) { - } -} \ No newline at end of file + public readonly array $actions, + ) {} +} diff --git a/src/Views/Dto/Notification/NotificationItemDto.php b/src/Views/Dto/Notification/NotificationItemDto.php index f398ec7..74fd77d 100644 --- a/src/Views/Dto/Notification/NotificationItemDto.php +++ b/src/Views/Dto/Notification/NotificationItemDto.php @@ -4,18 +4,15 @@ namespace Planka\Bridge\Views\Dto\Notification; -use DateTimeImmutable; - class NotificationItemDto { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public readonly bool $isRead, public readonly string $userId, public readonly string $cardId, - public readonly string $actionId - ) { - } -} \ No newline at end of file + public readonly string $actionId, + ) {} +} diff --git a/src/Views/Dto/Notification/NotificationListDto.php b/src/Views/Dto/Notification/NotificationListDto.php index 30847e9..2da4c04 100644 --- a/src/Views/Dto/Notification/NotificationListDto.php +++ b/src/Views/Dto/Notification/NotificationListDto.php @@ -8,11 +8,9 @@ class NotificationListDto { /** * @param list $items - * @param NotificationIncludedDto $included */ public function __construct( public readonly array $items, public readonly NotificationIncludedDto $included, - ) { - } -} \ No newline at end of file + ) {} +} diff --git a/src/Views/Dto/Project/ProjectDto.php b/src/Views/Dto/Project/ProjectDto.php index b9d5aca..4a91258 100644 --- a/src/Views/Dto/Project/ProjectDto.php +++ b/src/Views/Dto/Project/ProjectDto.php @@ -7,17 +7,15 @@ use Planka\Bridge\Views\Dto\Background\BackgroundImageDto; use Planka\Bridge\Views\Dto\Background\BackgroundDto; use Planka\Bridge\Contracts\Dto\OutputDtoInterface; -use DateTimeImmutable; class ProjectDto implements OutputDtoInterface { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, public string $name, public ?BackgroundDto $background, - public ?BackgroundImageDto $backgroundImage - ) { - } -} \ No newline at end of file + public ?BackgroundImageDto $backgroundImage, + ) {} +} diff --git a/src/Views/Dto/Project/ProjectIncludedDto.php b/src/Views/Dto/Project/ProjectIncludedDto.php index 7299e09..ba47b3a 100644 --- a/src/Views/Dto/Project/ProjectIncludedDto.php +++ b/src/Views/Dto/Project/ProjectIncludedDto.php @@ -12,16 +12,15 @@ class ProjectIncludedDto { /** - * @param list $users - * @param list $projectManagers - * @param list $boards + * @param list $users + * @param list $projectManagers + * @param list $boards * @param list $boardMemberships */ public function __construct( public array $users, public array $projectManagers, public array $boards, - public array $boardMemberships - ) { - } + public array $boardMemberships, + ) {} } diff --git a/src/Views/Dto/Project/ProjectListDto.php b/src/Views/Dto/Project/ProjectListDto.php index 8046511..f518bf7 100644 --- a/src/Views/Dto/Project/ProjectListDto.php +++ b/src/Views/Dto/Project/ProjectListDto.php @@ -8,11 +8,9 @@ class ProjectListDto { /** * @param list $items - * @param ProjectIncludedDto $included */ public function __construct( public readonly array $items, - public readonly ProjectIncludedDto $included - ) { - } -} \ No newline at end of file + public readonly ProjectIncludedDto $included, + ) {} +} diff --git a/src/Views/Dto/User/UserDto.php b/src/Views/Dto/User/UserDto.php index dc78349..ab443aa 100644 --- a/src/Views/Dto/User/UserDto.php +++ b/src/Views/Dto/User/UserDto.php @@ -5,15 +5,14 @@ namespace Planka\Bridge\Views\Dto\User; use Planka\Bridge\Contracts\Dto\OutputDtoInterface; -use DateTimeImmutable; class UserDto implements OutputDtoInterface { public function __construct( public readonly string $id, - public readonly DateTimeImmutable $createdAt, - public readonly ?DateTimeImmutable $updatedAt, - public readonly ?DateTimeImmutable $deletedAt, + public readonly \DateTimeImmutable $createdAt, + public readonly ?\DateTimeImmutable $updatedAt, + public readonly ?\DateTimeImmutable $deletedAt, public ?string $email, public bool $isAdmin, public ?string $name, @@ -22,7 +21,6 @@ public function __construct( public ?string $organization, public ?string $language, public bool $subscribeToOwnCards, - public ?string $avatarUrl - ) { - } -} \ No newline at end of file + public ?string $avatarUrl, + ) {} +} diff --git a/src/Views/Factory/Attachment/AttachmentDtoFactory.php b/src/Views/Factory/Attachment/AttachmentDtoFactory.php index 71fcf2f..7ac903a 100644 --- a/src/Views/Factory/Attachment/AttachmentDtoFactory.php +++ b/src/Views/Factory/Attachment/AttachmentDtoFactory.php @@ -25,7 +25,6 @@ final class AttachmentDtoFactory implements OutputInterface * creatorUserId: string, * image: array{height: int, width: int} * }|null $data - * @return ?AttachmentDto */ public function create(?array $data): ?AttachmentDto { @@ -42,7 +41,7 @@ public function create(?array $data): ?AttachmentDto createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), coverUrl: $data['coverUrl'], - image: (new ImageDtoFactory())->create($data['image'] ?? null) + image: (new ImageDtoFactory())->create($data['image'] ?? null), ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Background/BackgroundDtoFactory.php b/src/Views/Factory/Background/BackgroundDtoFactory.php index c1b292e..8cc9908 100644 --- a/src/Views/Factory/Background/BackgroundDtoFactory.php +++ b/src/Views/Factory/Background/BackgroundDtoFactory.php @@ -16,7 +16,6 @@ final class BackgroundDtoFactory implements OutputInterface * type: string, * name?: ?string * }|null $data - * @return ?BackgroundDto */ public function create(?array $data): ?BackgroundDto { @@ -26,7 +25,7 @@ public function create(?array $data): ?BackgroundDto return new BackgroundDto( type: BackgroundTypeEnum::from($data['type']), - name: BackgroundGradientEnum::tryFrom($data['name'] ?? '') + name: BackgroundGradientEnum::tryFrom($data['name'] ?? ''), ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Background/BackgroundImageDtoFactory.php b/src/Views/Factory/Background/BackgroundImageDtoFactory.php index 8143f78..6659366 100644 --- a/src/Views/Factory/Background/BackgroundImageDtoFactory.php +++ b/src/Views/Factory/Background/BackgroundImageDtoFactory.php @@ -14,7 +14,6 @@ final class BackgroundImageDtoFactory implements OutputInterface * url: string, * coverUrl: string * }|null $data - * @return ?BackgroundImageDto */ public function create(?array $data): ?BackgroundImageDto { @@ -24,7 +23,7 @@ public function create(?array $data): ?BackgroundImageDto return new BackgroundImageDto( url: $data['url'], - coverUrl: $data['coverUrl'] + coverUrl: $data['coverUrl'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Board/BoardDtoFactory.php b/src/Views/Factory/Board/BoardDtoFactory.php index 251c57e..26eea69 100644 --- a/src/Views/Factory/Board/BoardDtoFactory.php +++ b/src/Views/Factory/Board/BoardDtoFactory.php @@ -16,4 +16,4 @@ public function create(array $data): BoardDto included: (new BoardIncludedDtoFactory())->create($data['included'] ?? null), ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Board/BoardIncludedDtoFactory.php b/src/Views/Factory/Board/BoardIncludedDtoFactory.php index e628977..99c6474 100644 --- a/src/Views/Factory/Board/BoardIncludedDtoFactory.php +++ b/src/Views/Factory/Board/BoardIncludedDtoFactory.php @@ -1,6 +1,6 @@ getCardLabels($data), tasks: $this->getTasks($data), attachments: $this->getAttachments($data), - projects: $this->getProjects($data) + projects: $this->getProjects($data), ); } @@ -87,8 +87,9 @@ private function getUsers(array $data): array */ private function getBoardMemberships(array $data): array { - return map($data['boardMemberships'] ?? [], - fn(array $item) => (new BoardMembershipDtoFactory())->create($item) + return map( + $data['boardMemberships'] ?? [], + fn(array $item) => (new BoardMembershipDtoFactory())->create($item), ); } @@ -97,8 +98,9 @@ private function getBoardMemberships(array $data): array */ private function getLabels(array $data): array { - return map($data['labels'] ?? [], - fn(array $item) => (new LabelDtoFactory())->create($item) + return map( + $data['labels'] ?? [], + fn(array $item) => (new LabelDtoFactory())->create($item), ); } @@ -107,8 +109,9 @@ private function getLabels(array $data): array */ private function getLists(array $data): array { - return map($data['lists'] ?? [], - fn(array $item) => (new ListDtoFactory())->create($item) + return map( + $data['lists'] ?? [], + fn(array $item) => (new ListDtoFactory())->create($item), ); } @@ -117,8 +120,9 @@ private function getLists(array $data): array */ private function getCards(array $data): array { - return map($data['cards'] ?? [], - fn(array $item) => (new CardDtoFactory())->create(['item' => $item]) + return map( + $data['cards'] ?? [], + fn(array $item) => (new CardDtoFactory())->create(['item' => $item]), ); } @@ -127,8 +131,9 @@ private function getCards(array $data): array */ private function getCardMemberships(array $data): array { - return map($data['cardMemberships'] ?? [], - fn(array $item) => (new CardMembershipDtoFactory())->create($item) + return map( + $data['cardMemberships'] ?? [], + fn(array $item) => (new CardMembershipDtoFactory())->create($item), ); } @@ -137,8 +142,9 @@ private function getCardMemberships(array $data): array */ private function getCardLabels(array $data): array { - return map($data['cardLabels'] ?? [], - fn(array $item) => (new CardLabelDtoFactory())->create($item) + return map( + $data['cardLabels'] ?? [], + fn(array $item) => (new CardLabelDtoFactory())->create($item), ); } @@ -147,8 +153,9 @@ private function getCardLabels(array $data): array */ private function getTasks(array $data): array { - return map($data['tasks'] ?? [], - fn(array $item) => (new CardTaskDtoFactory())->create($item) + return map( + $data['tasks'] ?? [], + fn(array $item) => (new CardTaskDtoFactory())->create($item), ); } @@ -157,8 +164,9 @@ private function getTasks(array $data): array */ private function getAttachments(array $data): array { - return map($data['attachments'] ?? [], - fn(array $item) => (new AttachmentDtoFactory())->create($item) + return map( + $data['attachments'] ?? [], + fn(array $item) => (new AttachmentDtoFactory())->create($item), ); } @@ -167,8 +175,9 @@ private function getAttachments(array $data): array */ private function getProjects(array $data): array { - return map($data['projects'] ?? [], - fn(array $item) => (new ProjectDtoFactory())->create($item) + return map( + $data['projects'] ?? [], + fn(array $item) => (new ProjectDtoFactory())->create($item), ); } } diff --git a/src/Views/Factory/Board/BoardItemDtoFactory.php b/src/Views/Factory/Board/BoardItemDtoFactory.php index ecc6aaa..f7e4cfa 100644 --- a/src/Views/Factory/Board/BoardItemDtoFactory.php +++ b/src/Views/Factory/Board/BoardItemDtoFactory.php @@ -21,17 +21,16 @@ final class BoardItemDtoFactory implements OutputInterface * name: string, * projectId: string * } $data - * @return BoardItemDto */ public function create(array $data): BoardItemDto { return new BoardItemDto( id: $data['id'], projectId: $data['projectId'], - position: (int)$data['position'], + position: (int) $data['position'], name: $data['name'], createdAt: $this->convertToDateTime($data['createdAt']), - updatedAt: $this->convertToDateTime($data['updatedAt']) + updatedAt: $this->convertToDateTime($data['updatedAt']), ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Board/BoardListDtoFactory.php b/src/Views/Factory/Board/BoardListDtoFactory.php index 7bb7bbf..d022f30 100644 --- a/src/Views/Factory/Board/BoardListDtoFactory.php +++ b/src/Views/Factory/Board/BoardListDtoFactory.php @@ -21,7 +21,6 @@ final class BoardListDtoFactory implements OutputInterface * name: string, * boardId: string * } $data - * @return BoardListDto */ public function create(array $data): BoardListDto { @@ -29,9 +28,9 @@ public function create(array $data): BoardListDto id: $data['id'], createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), - position: (int)$data['position'], + position: (int) $data['position'], name: $data['name'], - boardId: $data['boardId'] + boardId: $data['boardId'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Board/BoardMembershipDtoFactory.php b/src/Views/Factory/Board/BoardMembershipDtoFactory.php index 09b6199..96b13ae 100644 --- a/src/Views/Factory/Board/BoardMembershipDtoFactory.php +++ b/src/Views/Factory/Board/BoardMembershipDtoFactory.php @@ -23,7 +23,6 @@ final class BoardMembershipDtoFactory implements OutputInterface * role: string, * boardId: string * } $data - * @return BoardMembershipDto */ public function create(array $data): BoardMembershipDto { @@ -32,9 +31,9 @@ public function create(array $data): BoardMembershipDto createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), userId: $data['userId'], - canComment: (bool)$data['canComment'], + canComment: (bool) $data['canComment'], role: BoardMembershipRoleEnum::from($data['role']), - boardId: $data['boardId'] + boardId: $data['boardId'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Card/CardActionItemDtoFactory.php b/src/Views/Factory/Card/CardActionItemDtoFactory.php index fdbfe13..e638b7b 100644 --- a/src/Views/Factory/Card/CardActionItemDtoFactory.php +++ b/src/Views/Factory/Card/CardActionItemDtoFactory.php @@ -23,7 +23,6 @@ final class CardActionItemDtoFactory implements OutputInterface * cardId: string, * userId: string * } $data - * @return CardActionItemDto */ public function create(array $data): CardActionItemDto { @@ -37,4 +36,4 @@ public function create(array $data): CardActionItemDto userId: $data['userId'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Card/CardActionListDtoFactory.php b/src/Views/Factory/Card/CardActionListDtoFactory.php index fe95c01..f672de5 100644 --- a/src/Views/Factory/Card/CardActionListDtoFactory.php +++ b/src/Views/Factory/Card/CardActionListDtoFactory.php @@ -9,6 +9,7 @@ use Planka\Bridge\Views\Dto\Card\CardActionItemDto; use Planka\Bridge\Views\Dto\Card\CardActionListDto; use Planka\Bridge\Views\Dto\User\UserDto; + use function Fp\Collection\map; final class CardActionListDtoFactory implements OutputInterface @@ -42,13 +43,12 @@ final class CardActionListDtoFactory implements OutputInterface * } * } * } $data - * @return CardActionListDto */ public function create(array $data): CardActionListDto { return new CardActionListDto( items: $this->getItems($data), - included: $this->getIncluded($data) + included: $this->getIncluded($data), ); } diff --git a/src/Views/Factory/Card/CardDtoFactory.php b/src/Views/Factory/Card/CardDtoFactory.php index e421b23..5e1e0a8 100644 --- a/src/Views/Factory/Card/CardDtoFactory.php +++ b/src/Views/Factory/Card/CardDtoFactory.php @@ -9,6 +9,7 @@ use Planka\Bridge\Views\Dto\Card\CardDto; use Planka\Bridge\Views\Dto\Card\CardIncludedDto; use Planka\Bridge\Views\Factory\Attachment\AttachmentDtoFactory; + use function Fp\Collection\map; final class CardDtoFactory implements OutputInterface @@ -73,7 +74,6 @@ final class CardDtoFactory implements OutputInterface * }, * } * } $data - * @return CardDto */ public function create(array $data): CardDto { @@ -83,7 +83,7 @@ public function create(array $data): CardDto id: $item['id'], createdAt: $this->convertToDateTime($item['createdAt']), updatedAt: $this->convertToDateTime($item['updatedAt']), - position: (int)$item['position'], + position: (int) $item['position'], name: $item['name'], description: $item['description'], dueDate: $this->convertToDateTime($item['dueDate']), @@ -93,8 +93,8 @@ public function create(array $data): CardDto listId: $item['listId'], creatorUserId: $item['creatorUserId'], coverAttachmentId: $item['coverAttachmentId'], - isSubscribed: (bool)($item['isSubscribed'] ?? false), - included: $this->getIncluded($data) + isSubscribed: (bool) ($item['isSubscribed'] ?? false), + included: $this->getIncluded($data), ); } @@ -103,9 +103,9 @@ private function getIncluded(array $data): CardIncludedDto if (!isset($data['included'])) { return new CardIncludedDto( cardMemberships: [], - cardLabels: [], - tasks: [], - attachments: [] + cardLabels: [], + tasks: [], + attachments: [], ); } @@ -113,7 +113,7 @@ private function getIncluded(array $data): CardIncludedDto cardMemberships: map($data['included']['cardMemberships'] ?? [], fn(array $item) => (new CardMembershipDtoFactory())->create($item)), cardLabels: map($data['included']['cardLabels'] ?? [], fn(array $item) => (new CardLabelDtoFactory())->create($item)), tasks: map($data['included']['tasks'] ?? [], fn(array $item) => (new CardTaskDtoFactory())->create($item)), - attachments: map($data['included']['attachments'] ?? [], fn(array $item) => (new AttachmentDtoFactory())->create($item)) + attachments: map($data['included']['attachments'] ?? [], fn(array $item) => (new AttachmentDtoFactory())->create($item)), ); } } diff --git a/src/Views/Factory/Card/CardLabelDtoFactory.php b/src/Views/Factory/Card/CardLabelDtoFactory.php index a04c69d..c9502c9 100644 --- a/src/Views/Factory/Card/CardLabelDtoFactory.php +++ b/src/Views/Factory/Card/CardLabelDtoFactory.php @@ -20,7 +20,6 @@ final class CardLabelDtoFactory implements OutputInterface * cardId: string, * labelId: ?string * } $data - * @return CardLabelDto */ public function create(array $data): CardLabelDto { @@ -29,7 +28,7 @@ public function create(array $data): CardLabelDto createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), cardId: $data['cardId'], - labelId: $data['labelId'] + labelId: $data['labelId'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Card/CardMembershipDtoFactory.php b/src/Views/Factory/Card/CardMembershipDtoFactory.php index 3ab69af..1a45a51 100644 --- a/src/Views/Factory/Card/CardMembershipDtoFactory.php +++ b/src/Views/Factory/Card/CardMembershipDtoFactory.php @@ -20,7 +20,6 @@ final class CardMembershipDtoFactory implements OutputInterface * cardId: string, * userId: string * } $data - * @return CardMembershipDto */ public function create(array $data): CardMembershipDto { @@ -29,7 +28,7 @@ public function create(array $data): CardMembershipDto createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), cardId: $data['cardId'], - userId: $data['userId'] + userId: $data['userId'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Card/CardTaskDtoFactory.php b/src/Views/Factory/Card/CardTaskDtoFactory.php index 3d5b0cd..f95b60c 100644 --- a/src/Views/Factory/Card/CardTaskDtoFactory.php +++ b/src/Views/Factory/Card/CardTaskDtoFactory.php @@ -22,7 +22,6 @@ final class CardTaskDtoFactory implements OutputInterface * isCompleted: bool, * cardId: string * } $data - * @return CardTaskDto */ public function create(array $data): CardTaskDto { @@ -30,10 +29,10 @@ public function create(array $data): CardTaskDto id: $data['id'], createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), - position: (int)$data['position'], + position: (int) $data['position'], name: $data['name'], - isCompleted: (bool)$data['isCompleted'], - cardId: $data['cardId'] + isCompleted: (bool) $data['isCompleted'], + cardId: $data['cardId'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Card/StopWatchDtoFactory.php b/src/Views/Factory/Card/StopWatchDtoFactory.php index 5c45ae6..c3eba6a 100644 --- a/src/Views/Factory/Card/StopWatchDtoFactory.php +++ b/src/Views/Factory/Card/StopWatchDtoFactory.php @@ -20,7 +20,7 @@ public function create(?array $data): ?StopWatchDto return new StopWatchDto( startedAt: $this->convertToDateTime($data['startedAt']), - total: (int)$data['total'] + total: (int) $data['total'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Comment/CommentDtoFactory.php b/src/Views/Factory/Comment/CommentDtoFactory.php index d291c0d..5c294b8 100644 --- a/src/Views/Factory/Comment/CommentDtoFactory.php +++ b/src/Views/Factory/Comment/CommentDtoFactory.php @@ -23,7 +23,6 @@ final class CommentDtoFactory implements OutputInterface * cardId: string, * userId: string * } $data - * @return CommentDto */ public function create(array $data): CommentDto { @@ -34,7 +33,7 @@ public function create(array $data): CommentDto cardId: $data['cardId'], userId: $data['userId'], type: CommentTypeEnum::from($data['type']), - dataText: $data['data']['text'] + dataText: $data['data']['text'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Image/ImageDtoFactory.php b/src/Views/Factory/Image/ImageDtoFactory.php index 53a3b55..c9d7914 100644 --- a/src/Views/Factory/Image/ImageDtoFactory.php +++ b/src/Views/Factory/Image/ImageDtoFactory.php @@ -16,8 +16,8 @@ public function create(?array $data): ?ImageDto } return new ImageDto( - height: (int)$data['height'], - width: (int)$data['width'] + height: (int) $data['height'], + width: (int) $data['width'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Label/LabelDtoFactory.php b/src/Views/Factory/Label/LabelDtoFactory.php index 66af7e7..aa53f8b 100644 --- a/src/Views/Factory/Label/LabelDtoFactory.php +++ b/src/Views/Factory/Label/LabelDtoFactory.php @@ -23,7 +23,6 @@ final class LabelDtoFactory implements OutputInterface * color: ?string, * boardId: string * } $data - * @return LabelDto */ public function create(array $data): LabelDto { @@ -32,9 +31,9 @@ public function create(array $data): LabelDto boardId: $data['boardId'], createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), - position: (int)$data['position'], + position: (int) $data['position'], name: $data['name'], - color: LabelColorEnum::tryFrom($data['color']) + color: LabelColorEnum::tryFrom($data['color']), ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/List/ListDtoFactory.php b/src/Views/Factory/List/ListDtoFactory.php index de7c857..da7a008 100644 --- a/src/Views/Factory/List/ListDtoFactory.php +++ b/src/Views/Factory/List/ListDtoFactory.php @@ -21,7 +21,6 @@ final class ListDtoFactory implements OutputInterface * name: string, * boardId: string * } $data - * @return ListDto */ public function create(array $data): ListDto { @@ -30,8 +29,8 @@ public function create(array $data): ListDto boardId: $data['boardId'], createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), - position: (int)$data['position'], - name: $data['name'] + position: (int) $data['position'], + name: $data['name'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Notification/NotificationIncludedDtoFactory.php b/src/Views/Factory/Notification/NotificationIncludedDtoFactory.php index 4bce90f..8addd6c 100644 --- a/src/Views/Factory/Notification/NotificationIncludedDtoFactory.php +++ b/src/Views/Factory/Notification/NotificationIncludedDtoFactory.php @@ -12,6 +12,7 @@ use Planka\Bridge\Views\Dto\Card\CardActionItemDto; use Planka\Bridge\Views\Dto\Card\CardDto; use Planka\Bridge\Views\Dto\User\UserDto; + use function Fp\Collection\map; final class NotificationIncludedDtoFactory implements OutputInterface @@ -22,14 +23,13 @@ final class NotificationIncludedDtoFactory implements OutputInterface * cards: array, * actions: array * } $data - * @return NotificationIncludedDto */ public function create(array $data): NotificationIncludedDto { return new NotificationIncludedDto( users: $this->getUsers($data), cards: $this->getCards($data), - actions: $this->getActions($data) + actions: $this->getActions($data), ); } @@ -46,8 +46,9 @@ private function getUsers(array $data): array */ private function getCards(array $data): array { - return map($data['cards'] ?? [], - fn(array $item) => (new CardDtoFactory())->create(['item' => $item]) + return map( + $data['cards'] ?? [], + fn(array $item) => (new CardDtoFactory())->create(['item' => $item]), ); } @@ -56,8 +57,9 @@ private function getCards(array $data): array */ private function getActions(array $data): array { - return map($data['actions'] ?? [], - fn(array $item) => (new CardActionItemDtoFactory())->create($item) + return map( + $data['actions'] ?? [], + fn(array $item) => (new CardActionItemDtoFactory())->create($item), ); } } diff --git a/src/Views/Factory/Notification/NotificationItemDtoFactory.php b/src/Views/Factory/Notification/NotificationItemDtoFactory.php index e36e9b6..241ba28 100644 --- a/src/Views/Factory/Notification/NotificationItemDtoFactory.php +++ b/src/Views/Factory/Notification/NotificationItemDtoFactory.php @@ -22,7 +22,6 @@ final class NotificationItemDtoFactory implements OutputInterface * actionId: string, * cardId: string * } $data - * @return NotificationItemDto */ public function create(array $data): NotificationItemDto { @@ -30,10 +29,10 @@ public function create(array $data): NotificationItemDto id: $data['id'], createdAt: $this->convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), - isRead: (bool)$data['isRead'], + isRead: (bool) $data['isRead'], userId: $data['userId'], cardId: $data['cardId'], - actionId: $data['actionId'] + actionId: $data['actionId'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Notification/NotificationListDtoFactory.php b/src/Views/Factory/Notification/NotificationListDtoFactory.php index f2fbb21..c84c2fa 100644 --- a/src/Views/Factory/Notification/NotificationListDtoFactory.php +++ b/src/Views/Factory/Notification/NotificationListDtoFactory.php @@ -8,6 +8,7 @@ use Planka\Bridge\Views\Dto\Notification\NotificationItemDto; use Planka\Bridge\Views\Dto\Notification\NotificationListDto; use Planka\Bridge\Contracts\Factory\OutputInterface; + use function Fp\Collection\map; final class NotificationListDtoFactory implements OutputInterface @@ -17,13 +18,12 @@ final class NotificationListDtoFactory implements OutputInterface * items: array, * included: array * } $data - * @return NotificationListDto */ public function create(array $data): NotificationListDto { return new NotificationListDto( items: $this->getItems($data), - included: $this->getIncluded($data) + included: $this->getIncluded($data), ); } @@ -39,4 +39,4 @@ private function getIncluded(array $data): NotificationIncludedDto { return (new NotificationIncludedDtoFactory())->create($data['included'] ?? []); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Project/ProjectDtoFactory.php b/src/Views/Factory/Project/ProjectDtoFactory.php index 3b5743e..4739b4e 100644 --- a/src/Views/Factory/Project/ProjectDtoFactory.php +++ b/src/Views/Factory/Project/ProjectDtoFactory.php @@ -23,7 +23,6 @@ final class ProjectDtoFactory implements OutputInterface * background: array{type: string,name?: ?string}|null, * backgroundImage: array{url: string, coverUrl: string}|null * } $data - * @return ProjectDto */ public function create(array $data): ProjectDto { @@ -33,7 +32,7 @@ public function create(array $data): ProjectDto updatedAt: $this->convertToDateTime($data['updatedAt']), name: $data['name'], background: (new BackgroundDtoFactory())->create($data['background'] ?? null), - backgroundImage: (new BackgroundImageDtoFactory())->create($data['backgroundImage'] ?? null) + backgroundImage: (new BackgroundImageDtoFactory())->create($data['backgroundImage'] ?? null), ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Project/ProjectIncludedDtoFactory.php b/src/Views/Factory/Project/ProjectIncludedDtoFactory.php index 1447da1..058365b 100644 --- a/src/Views/Factory/Project/ProjectIncludedDtoFactory.php +++ b/src/Views/Factory/Project/ProjectIncludedDtoFactory.php @@ -1,6 +1,6 @@ getUsers($data), projectManagers: $this->getProjectManagers($data), boards: $this->getBoards($data), - boardMemberships: $this->getBoardMemberships($data) + boardMemberships: $this->getBoardMemberships($data), ); } @@ -55,7 +56,9 @@ private function getBoards(array $data): array */ private function getBoardMemberships(array $data): array { - return map($data['boardMemberships'] ?? [], - fn(array $item) => (new BoardMembershipDtoFactory())->create($item)); + return map( + $data['boardMemberships'] ?? [], + fn(array $item) => (new BoardMembershipDtoFactory())->create($item), + ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Project/ProjectListDtoFactory.php b/src/Views/Factory/Project/ProjectListDtoFactory.php index 585b78a..d8cd8ea 100644 --- a/src/Views/Factory/Project/ProjectListDtoFactory.php +++ b/src/Views/Factory/Project/ProjectListDtoFactory.php @@ -8,6 +8,7 @@ use Planka\Bridge\Contracts\Factory\OutputInterface; use Planka\Bridge\Views\Dto\Project\ProjectListDto; use Planka\Bridge\Views\Dto\Project\ProjectDto; + use function Fp\Collection\map; final class ProjectListDtoFactory implements OutputInterface @@ -17,13 +18,12 @@ final class ProjectListDtoFactory implements OutputInterface * items: array, * included: array * } $data - * @return ProjectListDto */ public function create(array $data): ProjectListDto { return new ProjectListDto( items: $this->getItems($data), - included: $this->getIncluded($data) + included: $this->getIncluded($data), ); } @@ -32,8 +32,9 @@ public function create(array $data): ProjectListDto */ private function getItems(mixed $data): array { - return map($data['items'] ?? [], - fn(array $item) => (new ProjectDtoFactory())->create($item) + return map( + $data['items'] ?? [], + fn(array $item) => (new ProjectDtoFactory())->create($item), ); } @@ -41,4 +42,4 @@ private function getIncluded(mixed $data): ProjectIncludedDto { return (new ProjectIncludedDtoFactory())->create($data['included'] ?? []); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/Project/ProjectManagerDto.php b/src/Views/Factory/Project/ProjectManagerDto.php index 374f004..2db4787 100644 --- a/src/Views/Factory/Project/ProjectManagerDto.php +++ b/src/Views/Factory/Project/ProjectManagerDto.php @@ -1,19 +1,16 @@ convertToDateTime($data['createdAt']), updatedAt: $this->convertToDateTime($data['updatedAt']), projectId: $data['projectId'], - userId: $data['userId'] + userId: $data['userId'], ); } -} \ No newline at end of file +} diff --git a/src/Views/Factory/User/UserDtoFactory.php b/src/Views/Factory/User/UserDtoFactory.php index f8acc58..7d75b3f 100644 --- a/src/Views/Factory/User/UserDtoFactory.php +++ b/src/Views/Factory/User/UserDtoFactory.php @@ -28,7 +28,6 @@ final class UserDtoFactory implements OutputInterface * deletedAt: ?string, * avatarUrl: ?string, * } $data - * @return UserDto */ public function create(array $data): UserDto { @@ -38,14 +37,14 @@ public function create(array $data): UserDto updatedAt: $this->convertToDateTime($data['updatedAt']), deletedAt: $this->convertToDateTime($data['deletedAt']), email: $data['email'], - isAdmin: (bool)$data['isAdmin'], + isAdmin: (bool) $data['isAdmin'], name: $data['name'], username: $data['username'], phone: $data['phone'], organization: $data['organization'], language: $data['language'], - subscribeToOwnCards: (bool)$data['subscribeToOwnCards'], - avatarUrl: $data['avatarUrl'] ?? null + subscribeToOwnCards: (bool) $data['subscribeToOwnCards'], + avatarUrl: $data['avatarUrl'] ?? null, ); } -} \ No newline at end of file +} diff --git a/tests/config.example.php b/tests/config.example.php index 845b2b3..3a4ae49 100644 --- a/tests/config.example.php +++ b/tests/config.example.php @@ -1,8 +1,10 @@ 'http://192.168.1.2', 'port' => 3000, 'login' => 'email@email.com', 'password' => '12345678', -]; \ No newline at end of file +]; diff --git a/tests/index.php b/tests/index.php index 689a2d8..808fc73 100644 --- a/tests/index.php +++ b/tests/index.php @@ -1,5 +1,7 @@ getInfo()->getStatusCode() !== 200) { - die('Planka server not connected!'); +if (200 !== $client->getInfo()->getStatusCode()) { + exit('Planka server not connected!'); } if (!$client->authenticate()) { - die('User credentials not corrected!'); + exit('User credentials not corrected!'); } $filePath = __DIR__ . '/image.png'; @@ -41,7 +43,7 @@ try { $projectWithImage = $client->project->updateBackgroundImage($projectGet->id, $filePath); } catch (Throwable $exception) { - die('Upload image to project error'); + exit('Upload image to project error'); } // delete project background image @@ -105,7 +107,7 @@ try { $attachment = $client->attachment->upload($cardGet->id, $filePath); } catch (Throwable $exception) { - die('Upload attachment to card error'); + exit('Upload attachment to card error'); } // update name by attachment @@ -175,4 +177,4 @@ $client->board->delete($boardGet->item->id); // delete project -$client->project->delete($project->id); \ No newline at end of file +$client->project->delete($project->id); diff --git a/tests/subscribe.php b/tests/subscribe.php index ec61df6..e62536f 100644 --- a/tests/subscribe.php +++ b/tests/subscribe.php @@ -7,10 +7,11 @@ use Planka\Bridge\Config; use Planka\Bridge\PlankaClient; use Planka\Bridge\Views\Dto\Card\CardMembershipDto; + use function Fp\Collection\map; // copy config.example.php to config.php and setup for you -$config = include(__DIR__.'/config.php'); +$config = include __DIR__ . '/config.php'; require __DIR__ . '/../vendor/autoload.php'; @@ -18,16 +19,16 @@ user: $config['login'], password: $config['password'], baseUri: $config['uri'], - port: $config['port'] + port: $config['port'], ); $client = new PlankaClient($config); -if($client->getInfo()->getStatusCode() !== 200) { - die('Planka server not connected!'); +if (200 !== $client->getInfo()->getStatusCode()) { + exit('Planka server not connected!'); } if (!$client->authenticate()) { - die('User credentials not corrected!'); + exit('User credentials not corrected!'); } $list = $client->project->list(); @@ -59,7 +60,8 @@ $cardId = $item->id; // subscribe user on cards $client->card->subscribe($cardId, $userId); - } catch (Throwable $e) {} + } catch (Throwable $e) { + } } $boardInfo = $client->board->get($board->id); @@ -93,5 +95,6 @@ // subscribe user on cards $client->card->unsubscribe($cardId, $userId); - } catch (Throwable $e) {} + } catch (Throwable $e) { + } } From 5d66f03b7a308db5faa7211b3e5d7a4733ae5f07 Mon Sep 17 00:00:00 2001 From: Galochkin Sergey Date: Sun, 1 Dec 2024 21:04:06 +0300 Subject: [PATCH 4/6] code style --- docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md | 2 +- src/Traits/AuthenticateTrait.php | 4 ++-- src/TransportClients/Client.php | 2 +- src/Views/Dto/Card/CardDto.php | 2 +- tests/subscribe.php | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md b/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md index 169a619..d65e9ac 100644 --- a/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md +++ b/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md @@ -83,7 +83,7 @@ foreach ($boardInfo->included->cards as $item) { ]), ]; - dump($info); + var_dump($info); } // If you need unsubscribe user on cards use this - $client->card->unsubscribe($cardId, $userId); diff --git a/src/Traits/AuthenticateTrait.php b/src/Traits/AuthenticateTrait.php index e6b624a..084c61f 100644 --- a/src/Traits/AuthenticateTrait.php +++ b/src/Traits/AuthenticateTrait.php @@ -8,12 +8,12 @@ trait AuthenticateTrait { private string $token; - public function getToken(): string + final public function getToken(): string { return $this->token; } - public function setToken(string $token): void + final public function setToken(string $token): void { $this->token = $token; } diff --git a/src/TransportClients/Client.php b/src/TransportClients/Client.php index 2865c52..34cda97 100644 --- a/src/TransportClients/Client.php +++ b/src/TransportClients/Client.php @@ -11,7 +11,7 @@ use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Component\HttpClient\HttpClient; -class Client +final class Client { private const URI_TEMPLATE = '%s:%u/%s'; diff --git a/src/Views/Dto/Card/CardDto.php b/src/Views/Dto/Card/CardDto.php index 1aae81a..59ad3ce 100644 --- a/src/Views/Dto/Card/CardDto.php +++ b/src/Views/Dto/Card/CardDto.php @@ -22,7 +22,7 @@ public function __construct( public string $listId, public string $creatorUserId, public ?string $coverAttachmentId, - public readonly bool $isSubscribed, + public bool $isSubscribed, public readonly CardIncludedDto $included, ) {} } diff --git a/tests/subscribe.php b/tests/subscribe.php index e62536f..060e428 100644 --- a/tests/subscribe.php +++ b/tests/subscribe.php @@ -81,7 +81,7 @@ ]), ]; - dump($info); + var_dump($info); } // unsubscribe From ec18144342c5db15ac94bee3f05406fed12513ba Mon Sep 17 00:00:00 2001 From: Galochkin Sergey Date: Sun, 1 Dec 2024 21:10:58 +0300 Subject: [PATCH 5/6] fix version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f10f3cb..873efbb 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "minimum-stability": "dev", "prefer-stable": true, - "version": "1.1.4", + "version": "1.2.0", "require": { "php": ">=8.1.0", "symfony/http-client": "^6.2", From 0716b551a11efb5b047288750c9f40403b601454 Mon Sep 17 00:00:00 2001 From: Galochkin Sergey Date: Sun, 1 Dec 2024 21:11:51 +0300 Subject: [PATCH 6/6] fix docs --- docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md b/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md index d65e9ac..8057546 100644 --- a/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md +++ b/docs/SUBSCRIBE_MEMBERSHIP_TO_CARD.md @@ -1,4 +1,4 @@ -# Example Subscribe and Unsubscribe ussr on cards +# Example Subscribe and Unsubscribe user on cards ```php