diff --git a/config/packages/api_platform.php b/config/packages/api_platform.php
index aa190472..f123fd2e 100644
--- a/config/packages/api_platform.php
+++ b/config/packages/api_platform.php
@@ -11,6 +11,13 @@
'mapping' => [
'paths' => ['%kernel.project_dir%/src/Api'],
],
+ // The wire format of the public API is snake_case (puzzle_id, is_private, ...);
+ // the PHP side follows the project's camelCase standard. The converter maps
+ // both directions (responses, request inputs, the OpenAPI schema and the
+ // propertyPath of validation violations) - adding a DTO property means
+ // writing it in camelCase, nothing else. Scoped to API Platform, the rest of
+ // the application's serializer is untouched.
+ 'name_converter' => 'serializer.name_converter.camel_case_to_snake_case',
'formats' => [
'json' => ['mime_types' => ['application/json']],
],
diff --git a/config/services.php b/config/services.php
index 91fd893a..a04bc975 100644
--- a/config/services.php
+++ b/config/services.php
@@ -14,6 +14,7 @@
use Sentry\Monolog\LogToSentryIssueHandler;
use Sentry\State\HubInterface;
use SpeedPuzzling\Web\Doctrine\RegexSchemaAssetFilter;
+use SpeedPuzzling\Web\Services\Api\ApiDtoNormalizer;
use SpeedPuzzling\Web\Services\Doctrine\FixDoctrineMigrationTableSchema;
use SpeedPuzzling\Web\Services\SentryTracesSampler;
use SpeedPuzzling\Web\Services\Storage\FailoverS3Adapter;
@@ -220,6 +221,11 @@
// API Resource Providers and Processors
$services->load('SpeedPuzzling\\Web\\Api\\', __DIR__ . '/../src/Api/**/{*Provider.php,*Processor.php}');
+ // The nested API DTOs are normalized with the same snake_case converter API Platform
+ // uses for the resources themselves (config/packages/api_platform.php)
+ $services->set(ApiDtoNormalizer::class)
+ ->arg('$nameConverter', service('serializer.name_converter.camel_case_to_snake_case'));
+
// Components
$services->load('SpeedPuzzling\\Web\\Component\\', __DIR__ . '/../src/Component/**/{*.php}');
diff --git a/docs/features/api/README.md b/docs/features/api/README.md
index 8c286eb7..1d729769 100644
--- a/docs/features/api/README.md
+++ b/docs/features/api/README.md
@@ -415,6 +415,16 @@ Full policy page at `/en/fair-use-policy` with 10 sections: welcome, rate limits
Configured in `config/packages/nelmio_cors.php` with `allow_origin: ['*']` globally.
+## Conventions: camelCase PHP, snake_case JSON
+
+The wire format of the API is snake_case (`puzzle_id`, `is_private`, `predicted_seconds`, ...) and is a contract. The PHP DTOs in `src/Api/V1` use the project's camelCase standard (`$puzzleId`) — the mapping is automatic in both directions:
+
+- `config/packages/api_platform.php` sets `name_converter: serializer.name_converter.camel_case_to_snake_case`, which API Platform applies to the resources it serializes, to request inputs (`puzzle_id` → `$puzzleId`), to the OpenAPI schema and to the `propertyPath` of validation violations;
+- `src/Services/Api/ApiDtoNormalizer.php` applies the same converter to the **nested** DTOs (statistics groups, cards inside a list, rating entries, ...), which the framework serializer would otherwise emit camelCase — scoped to `SpeedPuzzling\Web\Api\*` non-resource classes so nothing else in the application changes;
+- `phpcs.xml` enforces camelCase in `src/Api/` (`Squiz.NamingConventions.ValidVariableName`), so a snake_case property cannot come back.
+
+Adding a field therefore means writing it in camelCase; the JSON key follows. The 2026-08-19 migration was verified by a byte-identical OpenAPI export before/after and the full API test suite (which asserts JSON keys).
+
## Deprecated: V0 Legacy API
> **Deprecated** — Do not develop further. Kept for backward compatibility only.
diff --git a/phpcs.xml b/phpcs.xml
index 9e6286c7..d81cdcbe 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -25,6 +25,17 @@
+
+
+ src/Api/
+
+
+ src/Api/
+
diff --git a/src/Api/V1/AddCollectionItemInput.php b/src/Api/V1/AddCollectionItemInput.php
index fe607806..54951291 100644
--- a/src/Api/V1/AddCollectionItemInput.php
+++ b/src/Api/V1/AddCollectionItemInput.php
@@ -24,7 +24,7 @@
final class AddCollectionItemInput
{
#[Assert\NotBlank]
- public string $puzzle_id = '';
+ public string $puzzleId = '';
#[Assert\Length(max: 500)]
public null|string $comment = null;
diff --git a/src/Api/V1/AddCollectionItemProcessor.php b/src/Api/V1/AddCollectionItemProcessor.php
index 26a318b2..6f8e90b8 100644
--- a/src/Api/V1/AddCollectionItemProcessor.php
+++ b/src/Api/V1/AddCollectionItemProcessor.php
@@ -49,7 +49,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
$dbCollectionId = $collectionId === 'default' ? null : $collectionId;
// Validate here so an invalid/unknown id surfaces as 404 instead of a wrapped 500 from the handler
- $this->puzzleRepository->get($data->puzzle_id);
+ $this->puzzleRepository->get($data->puzzleId);
if ($dbCollectionId !== null) {
$collection = $this->collectionRepository->get($dbCollectionId);
@@ -68,13 +68,13 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
$this->messageBus->dispatch(
new AddPuzzleToCollection(
playerId: $playerId,
- puzzleId: $data->puzzle_id,
+ puzzleId: $data->puzzleId,
collectionId: $dbCollectionId,
comment: $data->comment,
),
);
- $item = $this->getCollectionItems->getByPuzzleIdAndPlayerId($data->puzzle_id, $playerId, $dbCollectionId);
+ $item = $this->getCollectionItems->getByPuzzleIdAndPlayerId($data->puzzleId, $playerId, $dbCollectionId);
if ($item === null) {
throw new \RuntimeException('Collection item was not found after adding it to the collection.');
@@ -84,14 +84,14 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
$insights = $this->puzzleResponseFactory->insightsFor([$item->puzzleId], solvesOfPlayerId: $playerId, includePrediction: true);
return new CollectionItemResponse(
- collection_item_id: $item->collectionItemId,
- puzzle_id: $item->puzzleId,
- puzzle_name: $item->puzzleName,
- manufacturer_name: $item->manufacturerName,
- pieces_count: $item->piecesCount,
+ collectionItemId: $item->collectionItemId,
+ puzzleId: $item->puzzleId,
+ puzzleName: $item->puzzleName,
+ manufacturerName: $item->manufacturerName,
+ piecesCount: $item->piecesCount,
image: $item->image,
comment: $item->comment,
- added_at: $item->addedAt->format('c'),
+ addedAt: $item->addedAt->format('c'),
statistics: $insights->statistics($item->puzzleId),
difficulty: $insights->difficulty($item->puzzleId),
prediction: $insights->prediction($item->puzzleId),
diff --git a/src/Api/V1/CollectionItemResponse.php b/src/Api/V1/CollectionItemResponse.php
index d575422e..0b6e56b6 100644
--- a/src/Api/V1/CollectionItemResponse.php
+++ b/src/Api/V1/CollectionItemResponse.php
@@ -19,14 +19,14 @@
final class CollectionItemResponse
{
public function __construct(
- public string $collection_item_id,
- public string $puzzle_id,
- public string $puzzle_name,
- public null|string $manufacturer_name,
- public int $pieces_count,
+ public string $collectionItemId,
+ public string $puzzleId,
+ public string $puzzleName,
+ public null|string $manufacturerName,
+ public int $piecesCount,
public null|string $image,
public null|string $comment,
- public string $added_at,
+ public string $addedAt,
public PuzzleStatisticsResponse $statistics,
public null|PuzzleDifficultyResponse $difficulty = null,
public null|TimePredictionResponse $prediction = null,
diff --git a/src/Api/V1/CollectionResponse.php b/src/Api/V1/CollectionResponse.php
index 4e806462..ad0a4248 100644
--- a/src/Api/V1/CollectionResponse.php
+++ b/src/Api/V1/CollectionResponse.php
@@ -7,7 +7,7 @@
final class CollectionResponse
{
public function __construct(
- public string $collection_id,
+ public string $collectionId,
public string $name,
public null|string $description,
public string $visibility,
diff --git a/src/Api/V1/CompetitionDetailResponse.php b/src/Api/V1/CompetitionDetailResponse.php
index 785ee255..4d9c6352 100644
--- a/src/Api/V1/CompetitionDetailResponse.php
+++ b/src/Api/V1/CompetitionDetailResponse.php
@@ -35,13 +35,13 @@ public function __construct(
public null|string $logo,
public null|string $description,
public null|string $location,
- public null|string $country_code,
- public bool $is_online,
- public null|string $date_from,
- public null|string $date_to,
+ public null|string $countryCode,
+ public bool $isOnline,
+ public null|string $dateFrom,
+ public null|string $dateTo,
public null|string $link,
- public null|string $registration_link,
- public null|string $results_link,
+ public null|string $registrationLink,
+ public null|string $resultsLink,
array $rounds,
) {
$this->rounds = $rounds;
diff --git a/src/Api/V1/CompetitionDetailResponseProvider.php b/src/Api/V1/CompetitionDetailResponseProvider.php
index 7aad1203..251d33b9 100644
--- a/src/Api/V1/CompetitionDetailResponseProvider.php
+++ b/src/Api/V1/CompetitionDetailResponseProvider.php
@@ -57,13 +57,13 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
logo: $competition->logo,
description: $competition->description,
location: $competition->location,
- country_code: $competition->locationCountryCode?->name,
- is_online: $competition->isOnline,
- date_from: $competition->dateFrom?->format('c'),
- date_to: $competition->dateTo?->format('c'),
+ countryCode: $competition->locationCountryCode?->name,
+ isOnline: $competition->isOnline,
+ dateFrom: $competition->dateFrom?->format('c'),
+ dateTo: $competition->dateTo?->format('c'),
link: $competition->link,
- registration_link: $competition->registrationLink,
- results_link: $competition->resultsLink,
+ registrationLink: $competition->registrationLink,
+ resultsLink: $competition->resultsLink,
rounds: $rounds,
);
}
@@ -73,8 +73,8 @@ private function mapRound(EditionRoundDetail $round): CompetitionRoundResponse
return new CompetitionRoundResponse(
id: $round->id,
name: $round->name,
- starts_at: $round->startsAt->format('c'),
- minutes_limit: $round->minutesLimit,
+ startsAt: $round->startsAt->format('c'),
+ minutesLimit: $round->minutesLimit,
category: $round->category->value,
puzzles: array_map($this->mapPuzzle(...), $round->puzzles),
);
@@ -85,9 +85,9 @@ private function mapPuzzle(EditionRoundPuzzle $puzzle): CompetitionRoundPuzzleRe
return new CompetitionRoundPuzzleResponse(
id: $puzzle->puzzleId,
name: $puzzle->puzzleName,
- pieces_count: $puzzle->piecesCount,
+ piecesCount: $puzzle->piecesCount,
image: $puzzle->puzzleImage,
- manufacturer_name: $puzzle->manufacturerName,
+ manufacturerName: $puzzle->manufacturerName,
);
}
}
diff --git a/src/Api/V1/CompetitionListItemResponse.php b/src/Api/V1/CompetitionListItemResponse.php
index fb35291d..45f8a920 100644
--- a/src/Api/V1/CompetitionListItemResponse.php
+++ b/src/Api/V1/CompetitionListItemResponse.php
@@ -13,14 +13,14 @@ public function __construct(
public null|string $slug,
public null|string $logo,
public null|string $location,
- public null|string $country_code,
- public bool $is_online,
- public null|string $date_from,
- public null|string $date_to,
+ public null|string $countryCode,
+ public bool $isOnline,
+ public null|string $dateFrom,
+ public null|string $dateTo,
public null|string $status,
public null|string $link,
- public null|string $registration_link,
- public null|string $results_link,
+ public null|string $registrationLink,
+ public null|string $resultsLink,
) {
}
}
diff --git a/src/Api/V1/CompetitionListResponseProvider.php b/src/Api/V1/CompetitionListResponseProvider.php
index 0c4ee633..4b3abd36 100644
--- a/src/Api/V1/CompetitionListResponseProvider.php
+++ b/src/Api/V1/CompetitionListResponseProvider.php
@@ -45,14 +45,14 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
slug: $event->slug,
logo: $event->logo,
location: $event->location,
- country_code: $event->locationCountryCode?->name,
- is_online: $event->isOnline,
- date_from: $event->dateFrom?->format('c'),
- date_to: $event->dateTo?->format('c'),
+ countryCode: $event->locationCountryCode?->name,
+ isOnline: $event->isOnline,
+ dateFrom: $event->dateFrom?->format('c'),
+ dateTo: $event->dateTo?->format('c'),
status: $event->eventStatus,
link: $event->link,
- registration_link: $event->registrationLink,
- results_link: $event->resultsLink,
+ registrationLink: $event->registrationLink,
+ resultsLink: $event->resultsLink,
),
$events,
);
diff --git a/src/Api/V1/CompetitionRoundPuzzleResponse.php b/src/Api/V1/CompetitionRoundPuzzleResponse.php
index f7d22379..ff89a5aa 100644
--- a/src/Api/V1/CompetitionRoundPuzzleResponse.php
+++ b/src/Api/V1/CompetitionRoundPuzzleResponse.php
@@ -9,9 +9,9 @@ final class CompetitionRoundPuzzleResponse
public function __construct(
public string $id,
public string $name,
- public int $pieces_count,
+ public int $piecesCount,
public null|string $image,
- public null|string $manufacturer_name,
+ public null|string $manufacturerName,
) {
}
}
diff --git a/src/Api/V1/CompetitionRoundResponse.php b/src/Api/V1/CompetitionRoundResponse.php
index 04e470a9..5b14623d 100644
--- a/src/Api/V1/CompetitionRoundResponse.php
+++ b/src/Api/V1/CompetitionRoundResponse.php
@@ -15,8 +15,8 @@ final class CompetitionRoundResponse
public function __construct(
public string $id,
public string $name,
- public null|string $starts_at,
- public int $minutes_limit,
+ public null|string $startsAt,
+ public int $minutesLimit,
public string $category,
array $puzzles,
) {
diff --git a/src/Api/V1/CreateCollectionProcessor.php b/src/Api/V1/CreateCollectionProcessor.php
index c5ee6ece..21fdec27 100644
--- a/src/Api/V1/CreateCollectionProcessor.php
+++ b/src/Api/V1/CreateCollectionProcessor.php
@@ -56,7 +56,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
);
return new CollectionResponse(
- collection_id: $collectionId,
+ collectionId: $collectionId,
name: $data->name,
description: $data->description,
visibility: $visibility->value,
diff --git a/src/Api/V1/CreateSolvingTimeInput.php b/src/Api/V1/CreateSolvingTimeInput.php
index bf03e6d2..07d4673c 100644
--- a/src/Api/V1/CreateSolvingTimeInput.php
+++ b/src/Api/V1/CreateSolvingTimeInput.php
@@ -35,7 +35,7 @@
final class CreateSolvingTimeInput
{
#[Assert\NotBlank]
- public string $puzzle_id = '';
+ public string $puzzleId = '';
#[Assert\NotBlank]
#[Assert\Regex(pattern: '/^\d{1,2}:\d{2}(:\d{2})?$/', message: 'Time must be in format HH:MM:SS or MM:SS')]
@@ -43,14 +43,14 @@ final class CreateSolvingTimeInput
public null|string $comment = null;
- public null|string $finished_at = null;
+ public null|string $finishedAt = null;
- public bool $first_attempt = false;
+ public bool $firstAttempt = false;
public bool $unboxed = false;
- public null|string $round_id = null;
+ public null|string $roundId = null;
/** @var array */
- public array $group_players = [];
+ public array $groupPlayers = [];
}
diff --git a/src/Api/V1/CreateSolvingTimeProcessor.php b/src/Api/V1/CreateSolvingTimeProcessor.php
index c04abf47..c1964203 100644
--- a/src/Api/V1/CreateSolvingTimeProcessor.php
+++ b/src/Api/V1/CreateSolvingTimeProcessor.php
@@ -53,26 +53,26 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
// Validate the optional round here so an invalid/unknown id surfaces as 404
// (CompetitionRoundNotFound is a NotFoundHttpException). The handler re-resolves
// the round to wire it onto the entity.
- if ($data->round_id !== null) {
- $this->competitionRoundRepository->get($data->round_id);
+ if ($data->roundId !== null) {
+ $this->competitionRoundRepository->get($data->roundId);
}
- $finishedAt = $data->finished_at !== null ? new DateTimeImmutable($data->finished_at) : null;
+ $finishedAt = $data->finishedAt !== null ? new DateTimeImmutable($data->finishedAt) : null;
$this->messageBus->dispatch(
new AddPuzzleSolvingTime(
timeId: $timeId,
userId: $userId,
- puzzleId: $data->puzzle_id,
+ puzzleId: $data->puzzleId,
competitionId: null,
time: $data->time,
comment: $data->comment,
finishedPuzzlesPhoto: null,
- groupPlayers: $data->group_players,
+ groupPlayers: $data->groupPlayers,
finishedAt: $finishedAt,
- firstAttempt: $data->first_attempt,
+ firstAttempt: $data->firstAttempt,
unboxed: $data->unboxed,
- roundId: $data->round_id,
+ roundId: $data->roundId,
),
);
@@ -81,14 +81,14 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
$timeSeconds = SolvingTime::fromUserInput($data->time)->seconds;
return new SolvingTimeResponse(
- time_id: $timeId->toString(),
- puzzle_id: $data->puzzle_id,
- time_seconds: $timeSeconds,
- finished_at: $finishedAt?->format('c'),
- first_attempt: $data->first_attempt,
+ timeId: $timeId->toString(),
+ puzzleId: $data->puzzleId,
+ timeSeconds: $timeSeconds,
+ finishedAt: $finishedAt?->format('c'),
+ firstAttempt: $data->firstAttempt,
unboxed: $data->unboxed,
comment: $data->comment,
- round_id: $data->round_id,
+ roundId: $data->roundId,
prediction: $this->predictionBefore($data, $timeSeconds, $timeId->toString()),
);
}
@@ -107,7 +107,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
private function predictionBefore(CreateSolvingTimeInput $data, null|int $timeSeconds, string $timeId): null|TimePredictionResponse
{
// A non-empty group_players list always makes a duo/team time (or fails in the handler)
- if ($data->group_players !== [] || $timeSeconds === null) {
+ if ($data->groupPlayers !== [] || $timeSeconds === null) {
return null;
}
@@ -122,7 +122,7 @@ private function predictionBefore(CreateSolvingTimeInput $data, null|int $timeSe
}
return TimePredictionResponse::fromResult(
- $this->getPlayerPrediction->forPuzzle($profile->playerId, $data->puzzle_id, excludeTimeId: $timeId),
+ $this->getPlayerPrediction->forPuzzle($profile->playerId, $data->puzzleId, excludeTimeId: $timeId),
);
}
}
diff --git a/src/Api/V1/CurrentUserResponse.php b/src/Api/V1/CurrentUserResponse.php
index dbf17c4b..0ee5fe30 100644
--- a/src/Api/V1/CurrentUserResponse.php
+++ b/src/Api/V1/CurrentUserResponse.php
@@ -49,12 +49,12 @@ public function __construct(
public null|string $bio,
public null|string $facebook,
public null|string $instagram,
- public bool $is_private,
- public bool $has_active_membership,
- public null|string $membership_ends_at,
- public bool $time_predictions_opted_out,
- public bool $ranking_opted_out,
- public bool $streak_opted_out,
+ public bool $isPrivate,
+ public bool $hasActiveMembership,
+ public null|string $membershipEndsAt,
+ public bool $timePredictionsOptedOut,
+ public bool $rankingOptedOut,
+ public bool $streakOptedOut,
public null|array $rating,
public null|array $skill,
public array $badges,
diff --git a/src/Api/V1/CurrentUserResponseProvider.php b/src/Api/V1/CurrentUserResponseProvider.php
index 3bc6a987..7f7dacca 100644
--- a/src/Api/V1/CurrentUserResponseProvider.php
+++ b/src/Api/V1/CurrentUserResponseProvider.php
@@ -55,15 +55,15 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
bio: $profile->bio,
facebook: $profile->facebook,
instagram: $profile->instagram,
- is_private: $profile->isPrivate,
- has_active_membership: $profile->activeMembership,
+ isPrivate: $profile->isPrivate,
+ hasActiveMembership: $profile->activeMembership,
// GetPlayerProfile coalesces a missing/expired membership to the 1970 epoch
// (GREATEST over COALESCEd columns), so the date is only meaningful - and
// only exposed - while the membership is active.
- membership_ends_at: $profile->activeMembership ? $profile->membershipEndsAt?->format('c') : null,
- time_predictions_opted_out: $profile->timePredictionsOptedOut,
- ranking_opted_out: $profile->rankingOptedOut,
- streak_opted_out: $profile->streakOptedOut,
+ membershipEndsAt: $profile->activeMembership ? $profile->membershipEndsAt?->format('c') : null,
+ timePredictionsOptedOut: $profile->timePredictionsOptedOut,
+ rankingOptedOut: $profile->rankingOptedOut,
+ streakOptedOut: $profile->streakOptedOut,
rating: $showsRanking ? $this->profileInsights->rating($profile->playerId) : null,
skill: $showsRanking && $this->tokenOwner->isMember() ? $this->profileInsights->skill($profile->playerId) : null,
badges: $this->profileInsights->badges($profile->playerId),
diff --git a/src/Api/V1/LendBorrowResponse.php b/src/Api/V1/LendBorrowResponse.php
index 9fa515d5..dff6a60d 100644
--- a/src/Api/V1/LendBorrowResponse.php
+++ b/src/Api/V1/LendBorrowResponse.php
@@ -60,7 +60,7 @@ final class LendBorrowResponse
* @param array $items
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
public int $count,
array $items,
) {
diff --git a/src/Api/V1/LentPuzzleCounterpartyResponse.php b/src/Api/V1/LentPuzzleCounterpartyResponse.php
index 7ed9799e..175dab8b 100644
--- a/src/Api/V1/LentPuzzleCounterpartyResponse.php
+++ b/src/Api/V1/LentPuzzleCounterpartyResponse.php
@@ -14,7 +14,7 @@
final class LentPuzzleCounterpartyResponse
{
public function __construct(
- public null|string $player_id,
+ public null|string $playerId,
public string $name,
) {
}
diff --git a/src/Api/V1/LentPuzzleResponse.php b/src/Api/V1/LentPuzzleResponse.php
index e2e9ecdf..7b451119 100644
--- a/src/Api/V1/LentPuzzleResponse.php
+++ b/src/Api/V1/LentPuzzleResponse.php
@@ -17,15 +17,15 @@ final class LentPuzzleResponse
public const string DIRECTION_BORROWED = 'borrowed';
public function __construct(
- public string $lent_puzzle_id,
+ public string $lentPuzzleId,
public string $direction,
- public string $puzzle_id,
- public string $puzzle_name,
- public null|string $manufacturer_name,
- public int $pieces_count,
+ public string $puzzleId,
+ public string $puzzleName,
+ public null|string $manufacturerName,
+ public int $piecesCount,
public null|string $image,
public LentPuzzleCounterpartyResponse $counterparty,
- public string $lent_at,
+ public string $lentAt,
public null|string $notes,
public PuzzleStatisticsResponse $statistics,
public null|PuzzleDifficultyResponse $difficulty,
diff --git a/src/Api/V1/LibraryCollectionResponse.php b/src/Api/V1/LibraryCollectionResponse.php
index 029de580..db7a737d 100644
--- a/src/Api/V1/LibraryCollectionResponse.php
+++ b/src/Api/V1/LibraryCollectionResponse.php
@@ -14,11 +14,11 @@
final class LibraryCollectionResponse
{
public function __construct(
- public string $collection_id,
+ public string $collectionId,
public string $name,
public null|string $description,
public string $visibility,
- public int $item_count,
+ public int $itemCount,
) {
}
}
diff --git a/src/Api/V1/LibraryLendBorrowSectionResponse.php b/src/Api/V1/LibraryLendBorrowSectionResponse.php
index 0b5e5085..9c73692e 100644
--- a/src/Api/V1/LibraryLendBorrowSectionResponse.php
+++ b/src/Api/V1/LibraryLendBorrowSectionResponse.php
@@ -13,8 +13,8 @@
final class LibraryLendBorrowSectionResponse
{
public function __construct(
- public int $lent_count,
- public int $borrowed_count,
+ public int $lentCount,
+ public int $borrowedCount,
public string $visibility,
) {
}
diff --git a/src/Api/V1/LibraryResponse.php b/src/Api/V1/LibraryResponse.php
index 8cb204e8..b3560883 100644
--- a/src/Api/V1/LibraryResponse.php
+++ b/src/Api/V1/LibraryResponse.php
@@ -61,12 +61,12 @@ final class LibraryResponse
* @param array $collections
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
array $collections,
public LibrarySectionResponse $unsolved,
public LibrarySectionResponse $wishlist,
- public LibraryLendBorrowSectionResponse $lend_borrow,
- public LibrarySellSwapSectionResponse $sell_swap,
+ public LibraryLendBorrowSectionResponse $lendBorrow,
+ public LibrarySellSwapSectionResponse $sellSwap,
public LibrarySectionResponse $solved,
) {
$this->collections = $collections;
diff --git a/src/Api/V1/MyCollectionItemsResponse.php b/src/Api/V1/MyCollectionItemsResponse.php
index ae1be1fe..c621d136 100644
--- a/src/Api/V1/MyCollectionItemsResponse.php
+++ b/src/Api/V1/MyCollectionItemsResponse.php
@@ -28,7 +28,7 @@ final class MyCollectionItemsResponse
* @param array $items
*/
public function __construct(
- public string $collection_id,
+ public string $collectionId,
public int $count,
array $items,
) {
diff --git a/src/Api/V1/MyCollectionItemsResponseProvider.php b/src/Api/V1/MyCollectionItemsResponseProvider.php
index 786f1f1a..0ff83b6b 100644
--- a/src/Api/V1/MyCollectionItemsResponseProvider.php
+++ b/src/Api/V1/MyCollectionItemsResponseProvider.php
@@ -59,18 +59,18 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
);
return new MyCollectionItemsResponse(
- collection_id: $collectionId,
+ collectionId: $collectionId,
count: count($items),
items: array_map(
static fn(CollectionItemOverview $item) => new CollectionItemResponse(
- collection_item_id: $item->collectionItemId,
- puzzle_id: $item->puzzleId,
- puzzle_name: $item->puzzleName,
- manufacturer_name: $item->manufacturerName,
- pieces_count: $item->piecesCount,
+ collectionItemId: $item->collectionItemId,
+ puzzleId: $item->puzzleId,
+ puzzleName: $item->puzzleName,
+ manufacturerName: $item->manufacturerName,
+ piecesCount: $item->piecesCount,
image: $item->image,
comment: $item->comment,
- added_at: $item->addedAt->format('c'),
+ addedAt: $item->addedAt->format('c'),
statistics: $insights->statistics($item->puzzleId),
difficulty: $insights->difficulty($item->puzzleId),
prediction: $insights->prediction($item->puzzleId),
diff --git a/src/Api/V1/MyCollectionsResponse.php b/src/Api/V1/MyCollectionsResponse.php
index abd88cc5..e1665493 100644
--- a/src/Api/V1/MyCollectionsResponse.php
+++ b/src/Api/V1/MyCollectionsResponse.php
@@ -28,7 +28,7 @@ final class MyCollectionsResponse
* @param array $collections
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
public int $count,
array $collections,
) {
diff --git a/src/Api/V1/MyCollectionsResponseProvider.php b/src/Api/V1/MyCollectionsResponseProvider.php
index 7cbc71ee..dc1a966b 100644
--- a/src/Api/V1/MyCollectionsResponseProvider.php
+++ b/src/Api/V1/MyCollectionsResponseProvider.php
@@ -38,7 +38,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
if ($systemItemCount > 0 || $collections === []) {
$responses[] = new CollectionResponse(
- collection_id: 'default',
+ collectionId: 'default',
name: 'Default Collection',
description: null,
visibility: 'private',
@@ -47,7 +47,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
foreach ($collections as $collection) {
$responses[] = new CollectionResponse(
- collection_id: $collection->collectionId ?? 'default',
+ collectionId: $collection->collectionId ?? 'default',
name: $collection->name,
description: $collection->description,
visibility: $collection->visibility->value,
@@ -55,7 +55,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
}
return new MyCollectionsResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($responses),
collections: $responses,
);
diff --git a/src/Api/V1/MyLendBorrowResponseProvider.php b/src/Api/V1/MyLendBorrowResponseProvider.php
index 4ac76e7c..1aaf9d76 100644
--- a/src/Api/V1/MyLendBorrowResponseProvider.php
+++ b/src/Api/V1/MyLendBorrowResponseProvider.php
@@ -34,7 +34,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$items = $this->itemsFactory->lendBorrow($playerId);
return new LendBorrowResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($items),
items: $items,
);
diff --git a/src/Api/V1/MyResultsResponse.php b/src/Api/V1/MyResultsResponse.php
index a77fdeda..54a14b62 100644
--- a/src/Api/V1/MyResultsResponse.php
+++ b/src/Api/V1/MyResultsResponse.php
@@ -44,7 +44,7 @@ final class MyResultsResponse
* @param array $results
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
public string $type,
public int $count,
array $results,
diff --git a/src/Api/V1/MyResultsResponseProvider.php b/src/Api/V1/MyResultsResponseProvider.php
index ddefcabc..8e621440 100644
--- a/src/Api/V1/MyResultsResponseProvider.php
+++ b/src/Api/V1/MyResultsResponseProvider.php
@@ -52,20 +52,20 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
);
return new MyResultsResponse(
- player_id: $playerId,
+ playerId: $playerId,
type: $type,
count: count($results),
results: array_map(
static fn(SolvedPuzzle $puzzle) => new PlayerResultResponse(
- time_id: $puzzle->timeId,
- puzzle_id: $puzzle->puzzleId,
- puzzle_name: $puzzle->puzzleName,
- manufacturer_name: $puzzle->manufacturerName,
- pieces_count: $puzzle->piecesCount,
- time_seconds: $puzzle->time,
- finished_at: $puzzle->finishedAt?->format('c'),
- first_attempt: $puzzle->firstAttempt,
- puzzle_image: $puzzle->puzzleImage,
+ timeId: $puzzle->timeId,
+ puzzleId: $puzzle->puzzleId,
+ puzzleName: $puzzle->puzzleName,
+ manufacturerName: $puzzle->manufacturerName,
+ piecesCount: $puzzle->piecesCount,
+ timeSeconds: $puzzle->time,
+ finishedAt: $puzzle->finishedAt?->format('c'),
+ firstAttempt: $puzzle->firstAttempt,
+ puzzleImage: $puzzle->puzzleImage,
comment: $puzzle->comment,
statistics: $insights->statistics($puzzle->puzzleId),
difficulty: $insights->difficulty($puzzle->puzzleId),
diff --git a/src/Api/V1/MySellSwapResponseProvider.php b/src/Api/V1/MySellSwapResponseProvider.php
index e376fcc6..49c18c41 100644
--- a/src/Api/V1/MySellSwapResponseProvider.php
+++ b/src/Api/V1/MySellSwapResponseProvider.php
@@ -33,7 +33,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$items = $this->itemsFactory->sellSwap($profile);
return new SellSwapResponse(
- player_id: $profile->playerId,
+ playerId: $profile->playerId,
count: count($items),
items: $items,
);
diff --git a/src/Api/V1/MyStatisticsResponse.php b/src/Api/V1/MyStatisticsResponse.php
index 66ffa0c2..8b319924 100644
--- a/src/Api/V1/MyStatisticsResponse.php
+++ b/src/Api/V1/MyStatisticsResponse.php
@@ -22,7 +22,7 @@
final class MyStatisticsResponse
{
public function __construct(
- public string $player_id,
+ public string $playerId,
public StatisticsGroupResponse $solo,
public StatisticsGroupResponse $duo,
public StatisticsGroupResponse $team,
diff --git a/src/Api/V1/MyStatisticsResponseProvider.php b/src/Api/V1/MyStatisticsResponseProvider.php
index 7cbb022c..45ab7bb7 100644
--- a/src/Api/V1/MyStatisticsResponseProvider.php
+++ b/src/Api/V1/MyStatisticsResponseProvider.php
@@ -34,7 +34,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$team = $this->getPlayerStatistics->team($playerId);
return new MyStatisticsResponse(
- player_id: $playerId,
+ playerId: $playerId,
solo: $this->mapStatistics($solo),
duo: $this->mapStatistics($duo),
team: $this->mapStatistics($team),
@@ -44,9 +44,9 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
private function mapStatistics(PlayerStatistics $stats): StatisticsGroupResponse
{
return new StatisticsGroupResponse(
- total_seconds: $stats->totalSeconds,
- total_pieces: $stats->totalPieces,
- solved_puzzles_count: $stats->solvedPuzzlesCount,
+ totalSeconds: $stats->totalSeconds,
+ totalPieces: $stats->totalPieces,
+ solvedPuzzlesCount: $stats->solvedPuzzlesCount,
);
}
}
diff --git a/src/Api/V1/MyUnsolvedPuzzlesResponseProvider.php b/src/Api/V1/MyUnsolvedPuzzlesResponseProvider.php
index 425cafde..0a90fce7 100644
--- a/src/Api/V1/MyUnsolvedPuzzlesResponseProvider.php
+++ b/src/Api/V1/MyUnsolvedPuzzlesResponseProvider.php
@@ -33,7 +33,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$items = $this->itemsFactory->unsolvedPuzzles($playerId);
return new UnsolvedPuzzlesResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($items),
items: $items,
);
diff --git a/src/Api/V1/MyWishlistResponseProvider.php b/src/Api/V1/MyWishlistResponseProvider.php
index 057db81a..2534a8dd 100644
--- a/src/Api/V1/MyWishlistResponseProvider.php
+++ b/src/Api/V1/MyWishlistResponseProvider.php
@@ -32,7 +32,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$items = $this->itemsFactory->wishlist($playerId);
return new WishlistResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($items),
items: $items,
);
diff --git a/src/Api/V1/PlayerCollectionItemsResponse.php b/src/Api/V1/PlayerCollectionItemsResponse.php
index aab57f9a..223a4c50 100644
--- a/src/Api/V1/PlayerCollectionItemsResponse.php
+++ b/src/Api/V1/PlayerCollectionItemsResponse.php
@@ -28,7 +28,7 @@ final class PlayerCollectionItemsResponse
* @param array $items
*/
public function __construct(
- public string $collection_id,
+ public string $collectionId,
public int $count,
array $items,
) {
diff --git a/src/Api/V1/PlayerCollectionItemsResponseProvider.php b/src/Api/V1/PlayerCollectionItemsResponseProvider.php
index 96b5fa3f..17dde34a 100644
--- a/src/Api/V1/PlayerCollectionItemsResponseProvider.php
+++ b/src/Api/V1/PlayerCollectionItemsResponseProvider.php
@@ -63,7 +63,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
if ($this->isVisibleToTokenOwner($profile, $dbCollectionId) === false) {
return new PlayerCollectionItemsResponse(
- collection_id: $collectionId,
+ collectionId: $collectionId,
count: 0,
items: [],
);
@@ -81,18 +81,18 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
);
return new PlayerCollectionItemsResponse(
- collection_id: $collectionId,
+ collectionId: $collectionId,
count: count($items),
items: array_map(
static fn(CollectionItemOverview $item) => new CollectionItemResponse(
- collection_item_id: $item->collectionItemId,
- puzzle_id: $item->puzzleId,
- puzzle_name: $item->puzzleName,
- manufacturer_name: $item->manufacturerName,
- pieces_count: $item->piecesCount,
+ collectionItemId: $item->collectionItemId,
+ puzzleId: $item->puzzleId,
+ puzzleName: $item->puzzleName,
+ manufacturerName: $item->manufacturerName,
+ piecesCount: $item->piecesCount,
image: $item->image,
comment: $item->comment,
- added_at: $item->addedAt->format('c'),
+ addedAt: $item->addedAt->format('c'),
statistics: $insights->statistics($item->puzzleId),
difficulty: $insights->difficulty($item->puzzleId),
prediction: $insights->prediction($item->puzzleId),
diff --git a/src/Api/V1/PlayerCollectionsResponse.php b/src/Api/V1/PlayerCollectionsResponse.php
index f1fadf53..70e3a3cc 100644
--- a/src/Api/V1/PlayerCollectionsResponse.php
+++ b/src/Api/V1/PlayerCollectionsResponse.php
@@ -28,7 +28,7 @@ final class PlayerCollectionsResponse
* @param array $collections
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
public int $count,
array $collections,
) {
diff --git a/src/Api/V1/PlayerCollectionsResponseProvider.php b/src/Api/V1/PlayerCollectionsResponseProvider.php
index 75eb116a..c783ed63 100644
--- a/src/Api/V1/PlayerCollectionsResponseProvider.php
+++ b/src/Api/V1/PlayerCollectionsResponseProvider.php
@@ -29,7 +29,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
if ($profile->isPrivate) {
return new PlayerCollectionsResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: 0,
collections: [],
);
@@ -39,7 +39,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$responses = array_map(
static fn($collection) => new CollectionResponse(
- collection_id: $collection->collectionId ?? 'default',
+ collectionId: $collection->collectionId ?? 'default',
name: $collection->name,
description: $collection->description,
visibility: $collection->visibility->value,
@@ -48,7 +48,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
);
return new PlayerCollectionsResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($responses),
collections: $responses,
);
diff --git a/src/Api/V1/PlayerLendBorrowResponseProvider.php b/src/Api/V1/PlayerLendBorrowResponseProvider.php
index 72e4b9db..b9e8534b 100644
--- a/src/Api/V1/PlayerLendBorrowResponseProvider.php
+++ b/src/Api/V1/PlayerLendBorrowResponseProvider.php
@@ -41,7 +41,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
: [];
return new LendBorrowResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($items),
items: $items,
);
diff --git a/src/Api/V1/PlayerProfileResponse.php b/src/Api/V1/PlayerProfileResponse.php
index c4861ee3..268c0d2a 100644
--- a/src/Api/V1/PlayerProfileResponse.php
+++ b/src/Api/V1/PlayerProfileResponse.php
@@ -69,8 +69,8 @@ public function __construct(
public null|string $bio,
public null|string $facebook,
public null|string $instagram,
- public bool $is_private,
- public bool $has_active_membership,
+ public bool $isPrivate,
+ public bool $hasActiveMembership,
public null|array $rating,
public null|array $skill,
public array $badges,
@@ -93,8 +93,8 @@ public static function masked(PlayerProfile $profile): self
bio: null,
facebook: null,
instagram: null,
- is_private: true,
- has_active_membership: $profile->activeMembership,
+ isPrivate: true,
+ hasActiveMembership: $profile->activeMembership,
rating: null,
skill: null,
badges: [],
diff --git a/src/Api/V1/PlayerProfileResponseProvider.php b/src/Api/V1/PlayerProfileResponseProvider.php
index 964cfeb1..6e7a277a 100644
--- a/src/Api/V1/PlayerProfileResponseProvider.php
+++ b/src/Api/V1/PlayerProfileResponseProvider.php
@@ -59,8 +59,8 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
bio: $profile->bio,
facebook: $profile->facebook,
instagram: $profile->instagram,
- is_private: $profile->isPrivate,
- has_active_membership: $profile->activeMembership,
+ isPrivate: $profile->isPrivate,
+ hasActiveMembership: $profile->activeMembership,
rating: $showsRanking ? $this->profileInsights->rating($profile->playerId) : null,
skill: $showsRanking && $this->tokenOwner->isMember() ? $this->profileInsights->skill($profile->playerId) : null,
badges: $this->profileInsights->badges($profile->playerId),
diff --git a/src/Api/V1/PlayerRatingResponse.php b/src/Api/V1/PlayerRatingResponse.php
index 915781bd..115e07d4 100644
--- a/src/Api/V1/PlayerRatingResponse.php
+++ b/src/Api/V1/PlayerRatingResponse.php
@@ -17,10 +17,10 @@
final class PlayerRatingResponse
{
public function __construct(
- public int $pieces_count,
+ public int $piecesCount,
public int $points,
public int $rank,
- public int $total_players,
+ public int $totalPlayers,
) {
}
@@ -30,10 +30,10 @@ public function __construct(
public static function fromRating(int $piecesCount, array $rating): self
{
return new self(
- pieces_count: $piecesCount,
+ piecesCount: $piecesCount,
points: (int) round($rating['elo_rating'] * 1000),
rank: $rating['rank'],
- total_players: $rating['total'],
+ totalPlayers: $rating['total'],
);
}
}
diff --git a/src/Api/V1/PlayerResultResponse.php b/src/Api/V1/PlayerResultResponse.php
index fc6ab711..d235bedd 100644
--- a/src/Api/V1/PlayerResultResponse.php
+++ b/src/Api/V1/PlayerResultResponse.php
@@ -13,15 +13,15 @@
final class PlayerResultResponse
{
public function __construct(
- public string $time_id,
- public string $puzzle_id,
- public string $puzzle_name,
- public string $manufacturer_name,
- public int $pieces_count,
- public null|int $time_seconds,
- public null|string $finished_at,
- public bool $first_attempt,
- public null|string $puzzle_image,
+ public string $timeId,
+ public string $puzzleId,
+ public string $puzzleName,
+ public string $manufacturerName,
+ public int $piecesCount,
+ public null|int $timeSeconds,
+ public null|string $finishedAt,
+ public bool $firstAttempt,
+ public null|string $puzzleImage,
public null|string $comment,
public PuzzleStatisticsResponse $statistics,
public null|PuzzleDifficultyResponse $difficulty = null,
diff --git a/src/Api/V1/PlayerResultsResponse.php b/src/Api/V1/PlayerResultsResponse.php
index b7a4f0cc..97d361ac 100644
--- a/src/Api/V1/PlayerResultsResponse.php
+++ b/src/Api/V1/PlayerResultsResponse.php
@@ -44,7 +44,7 @@ final class PlayerResultsResponse
* @param array $results
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
public string $type,
public int $count,
array $results,
diff --git a/src/Api/V1/PlayerResultsResponseProvider.php b/src/Api/V1/PlayerResultsResponseProvider.php
index 5f0700d8..afae569f 100644
--- a/src/Api/V1/PlayerResultsResponseProvider.php
+++ b/src/Api/V1/PlayerResultsResponseProvider.php
@@ -37,7 +37,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
if ($profile->isPrivate) {
return new PlayerResultsResponse(
- player_id: $playerId,
+ playerId: $playerId,
type: $type,
count: 0,
results: [],
@@ -60,20 +60,20 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
);
return new PlayerResultsResponse(
- player_id: $playerId,
+ playerId: $playerId,
type: $type,
count: count($results),
results: array_map(
static fn(SolvedPuzzle $puzzle) => new PlayerResultResponse(
- time_id: $puzzle->timeId,
- puzzle_id: $puzzle->puzzleId,
- puzzle_name: $puzzle->puzzleName,
- manufacturer_name: $puzzle->manufacturerName,
- pieces_count: $puzzle->piecesCount,
- time_seconds: $puzzle->time,
- finished_at: $puzzle->finishedAt?->format('c'),
- first_attempt: $puzzle->firstAttempt,
- puzzle_image: $puzzle->puzzleImage,
+ timeId: $puzzle->timeId,
+ puzzleId: $puzzle->puzzleId,
+ puzzleName: $puzzle->puzzleName,
+ manufacturerName: $puzzle->manufacturerName,
+ piecesCount: $puzzle->piecesCount,
+ timeSeconds: $puzzle->time,
+ finishedAt: $puzzle->finishedAt?->format('c'),
+ firstAttempt: $puzzle->firstAttempt,
+ puzzleImage: $puzzle->puzzleImage,
comment: $puzzle->comment,
statistics: $insights->statistics($puzzle->puzzleId),
difficulty: $insights->difficulty($puzzle->puzzleId),
diff --git a/src/Api/V1/PlayerSellSwapResponseProvider.php b/src/Api/V1/PlayerSellSwapResponseProvider.php
index b47ccfd0..024133fb 100644
--- a/src/Api/V1/PlayerSellSwapResponseProvider.php
+++ b/src/Api/V1/PlayerSellSwapResponseProvider.php
@@ -42,7 +42,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
: [];
return new SellSwapResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($items),
items: $items,
);
diff --git a/src/Api/V1/PlayerSkillResponse.php b/src/Api/V1/PlayerSkillResponse.php
index 4de942e5..335c3a8e 100644
--- a/src/Api/V1/PlayerSkillResponse.php
+++ b/src/Api/V1/PlayerSkillResponse.php
@@ -19,22 +19,22 @@
final class PlayerSkillResponse
{
public function __construct(
- public int $pieces_count,
+ public int $piecesCount,
public string $tier,
public float $percentile,
public string $confidence,
- public int $qualifying_puzzles_count,
+ public int $qualifyingPuzzlesCount,
) {
}
public static function fromResult(PlayerSkillResult $skill): self
{
return new self(
- pieces_count: $skill->piecesCount,
+ piecesCount: $skill->piecesCount,
tier: $skill->skillTier->toApiValue(),
percentile: $skill->skillPercentile,
confidence: $skill->confidence->value,
- qualifying_puzzles_count: $skill->qualifyingPuzzlesCount,
+ qualifyingPuzzlesCount: $skill->qualifyingPuzzlesCount,
);
}
}
diff --git a/src/Api/V1/PlayerStatisticsResponse.php b/src/Api/V1/PlayerStatisticsResponse.php
index feed53ea..5623b1ad 100644
--- a/src/Api/V1/PlayerStatisticsResponse.php
+++ b/src/Api/V1/PlayerStatisticsResponse.php
@@ -22,7 +22,7 @@
final class PlayerStatisticsResponse
{
public function __construct(
- public string $player_id,
+ public string $playerId,
public StatisticsGroupResponse $solo,
public StatisticsGroupResponse $duo,
public StatisticsGroupResponse $team,
diff --git a/src/Api/V1/PlayerStatisticsResponseProvider.php b/src/Api/V1/PlayerStatisticsResponseProvider.php
index 2de13d23..56e8b290 100644
--- a/src/Api/V1/PlayerStatisticsResponseProvider.php
+++ b/src/Api/V1/PlayerStatisticsResponseProvider.php
@@ -29,14 +29,14 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$profile = $this->getPlayerProfile->byId($playerId);
$emptyStats = new StatisticsGroupResponse(
- total_seconds: 0,
- total_pieces: 0,
- solved_puzzles_count: 0,
+ totalSeconds: 0,
+ totalPieces: 0,
+ solvedPuzzlesCount: 0,
);
if ($profile->isPrivate) {
return new PlayerStatisticsResponse(
- player_id: $playerId,
+ playerId: $playerId,
solo: $emptyStats,
duo: $emptyStats,
team: $emptyStats,
@@ -48,7 +48,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
$team = $this->getPlayerStatistics->team($playerId);
return new PlayerStatisticsResponse(
- player_id: $playerId,
+ playerId: $playerId,
solo: $this->mapStatistics($solo),
duo: $this->mapStatistics($duo),
team: $this->mapStatistics($team),
@@ -58,9 +58,9 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
private function mapStatistics(PlayerStatistics $stats): StatisticsGroupResponse
{
return new StatisticsGroupResponse(
- total_seconds: $stats->totalSeconds,
- total_pieces: $stats->totalPieces,
- solved_puzzles_count: $stats->solvedPuzzlesCount,
+ totalSeconds: $stats->totalSeconds,
+ totalPieces: $stats->totalPieces,
+ solvedPuzzlesCount: $stats->solvedPuzzlesCount,
);
}
}
diff --git a/src/Api/V1/PlayerUnsolvedPuzzlesResponseProvider.php b/src/Api/V1/PlayerUnsolvedPuzzlesResponseProvider.php
index 5eaba36b..78d8c483 100644
--- a/src/Api/V1/PlayerUnsolvedPuzzlesResponseProvider.php
+++ b/src/Api/V1/PlayerUnsolvedPuzzlesResponseProvider.php
@@ -41,7 +41,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
: [];
return new UnsolvedPuzzlesResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($items),
items: $items,
);
diff --git a/src/Api/V1/PlayerWishlistResponseProvider.php b/src/Api/V1/PlayerWishlistResponseProvider.php
index f0be9a87..bac88f64 100644
--- a/src/Api/V1/PlayerWishlistResponseProvider.php
+++ b/src/Api/V1/PlayerWishlistResponseProvider.php
@@ -41,7 +41,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
: [];
return new WishlistResponse(
- player_id: $playerId,
+ playerId: $playerId,
count: count($items),
items: $items,
);
diff --git a/src/Api/V1/PredictedTimeResponse.php b/src/Api/V1/PredictedTimeResponse.php
index 97451d5c..2de12671 100644
--- a/src/Api/V1/PredictedTimeResponse.php
+++ b/src/Api/V1/PredictedTimeResponse.php
@@ -30,16 +30,16 @@
final class PredictedTimeResponse
{
public function __construct(
- public string $puzzle_id,
- public null|int $predicted_seconds,
- public null|int $range_low_seconds,
- public null|int $range_high_seconds,
- public bool $is_personalized,
- public null|int $personal_solve_count,
- public null|int $last_time_seconds,
- public null|float $difficulty_score,
- public null|string $difficulty_level,
- public null|string $difficulty_confidence,
+ public string $puzzleId,
+ public null|int $predictedSeconds,
+ public null|int $rangeLowSeconds,
+ public null|int $rangeHighSeconds,
+ public bool $isPersonalized,
+ public null|int $personalSolveCount,
+ public null|int $lastTimeSeconds,
+ public null|float $difficultyScore,
+ public null|string $difficultyLevel,
+ public null|string $difficultyConfidence,
) {
}
@@ -50,16 +50,16 @@ public function __construct(
public static function membersOnly(string $puzzleId): self
{
return new self(
- puzzle_id: $puzzleId,
- predicted_seconds: null,
- range_low_seconds: null,
- range_high_seconds: null,
- is_personalized: false,
- personal_solve_count: null,
- last_time_seconds: null,
- difficulty_score: null,
- difficulty_level: null,
- difficulty_confidence: null,
+ puzzleId: $puzzleId,
+ predictedSeconds: null,
+ rangeLowSeconds: null,
+ rangeHighSeconds: null,
+ isPersonalized: false,
+ personalSolveCount: null,
+ lastTimeSeconds: null,
+ difficultyScore: null,
+ difficultyLevel: null,
+ difficultyConfidence: null,
);
}
@@ -76,16 +76,16 @@ public static function fromInsights(
null|PuzzleDifficultyResponse $difficulty,
): self {
return new self(
- puzzle_id: $puzzleId,
- predicted_seconds: $prediction->predicted_seconds,
- range_low_seconds: $prediction->range_low_seconds,
- range_high_seconds: $prediction->range_high_seconds,
- is_personalized: $prediction->is_personalized,
- personal_solve_count: $prediction->personal_solve_count,
- last_time_seconds: $prediction->last_time_seconds,
- difficulty_score: $difficulty?->score,
- difficulty_level: $difficulty?->level,
- difficulty_confidence: $difficulty?->confidence,
+ puzzleId: $puzzleId,
+ predictedSeconds: $prediction->predictedSeconds,
+ rangeLowSeconds: $prediction->rangeLowSeconds,
+ rangeHighSeconds: $prediction->rangeHighSeconds,
+ isPersonalized: $prediction->isPersonalized,
+ personalSolveCount: $prediction->personalSolveCount,
+ lastTimeSeconds: $prediction->lastTimeSeconds,
+ difficultyScore: $difficulty?->score,
+ difficultyLevel: $difficulty?->level,
+ difficultyConfidence: $difficulty?->confidence,
);
}
}
diff --git a/src/Api/V1/PuzzleDetailResponse.php b/src/Api/V1/PuzzleDetailResponse.php
index b5498885..6691d817 100644
--- a/src/Api/V1/PuzzleDetailResponse.php
+++ b/src/Api/V1/PuzzleDetailResponse.php
@@ -55,14 +55,14 @@ final class PuzzleDetailResponse
public function __construct(
public string $id,
public string $name,
- public null|string $alternative_name,
+ public null|string $alternativeName,
public PuzzleManufacturerResponse $manufacturer,
- public int $pieces_count,
+ public int $piecesCount,
public null|string $image,
public null|string $ean,
- public null|string $identification_number,
- public bool $is_available,
- public bool $is_approved,
+ public null|string $identificationNumber,
+ public bool $isAvailable,
+ public bool $isApproved,
public PuzzleStatisticsResponse $statistics,
public null|PuzzleDifficultyResponse $difficulty,
public null|TimePredictionResponse $prediction,
@@ -79,14 +79,14 @@ public static function fromCard(PuzzleResponse $card): self
return new self(
id: $card->id,
name: $card->name,
- alternative_name: $card->alternative_name,
+ alternativeName: $card->alternativeName,
manufacturer: $card->manufacturer,
- pieces_count: $card->pieces_count,
+ piecesCount: $card->piecesCount,
image: $card->image,
ean: $card->ean,
- identification_number: $card->identification_number,
- is_available: $card->is_available,
- is_approved: $card->is_approved,
+ identificationNumber: $card->identificationNumber,
+ isAvailable: $card->isAvailable,
+ isApproved: $card->isApproved,
statistics: $card->statistics,
difficulty: $card->difficulty,
prediction: $card->prediction,
diff --git a/src/Api/V1/PuzzleDifficultyResponse.php b/src/Api/V1/PuzzleDifficultyResponse.php
index bcbfcd4d..b25743ef 100644
--- a/src/Api/V1/PuzzleDifficultyResponse.php
+++ b/src/Api/V1/PuzzleDifficultyResponse.php
@@ -19,7 +19,7 @@ public function __construct(
public null|float $score,
public null|string $level,
public string $confidence,
- public int $sample_size,
+ public int $sampleSize,
) {
}
@@ -29,7 +29,7 @@ public static function fromResult(PuzzleDifficultyResult $difficulty): self
score: $difficulty->difficultyScore,
level: $difficulty->difficultyTier?->toApiValue(),
confidence: $difficulty->confidence->value,
- sample_size: $difficulty->sampleSize,
+ sampleSize: $difficulty->sampleSize,
);
}
@@ -43,7 +43,7 @@ public static function insufficient(): self
score: null,
level: null,
confidence: MetricConfidence::Insufficient->value,
- sample_size: 0,
+ sampleSize: 0,
);
}
}
diff --git a/src/Api/V1/PuzzleListResponse.php b/src/Api/V1/PuzzleListResponse.php
index ac871fcd..22c85c30 100644
--- a/src/Api/V1/PuzzleListResponse.php
+++ b/src/Api/V1/PuzzleListResponse.php
@@ -137,7 +137,7 @@ public function __construct(
public int $total,
public int $page,
public int $limit,
- public bool $has_more,
+ public bool $hasMore,
/** @var list */
public array $puzzles,
) {
diff --git a/src/Api/V1/PuzzleResponse.php b/src/Api/V1/PuzzleResponse.php
index d7825a02..5d8683b8 100644
--- a/src/Api/V1/PuzzleResponse.php
+++ b/src/Api/V1/PuzzleResponse.php
@@ -18,14 +18,14 @@ final class PuzzleResponse
public function __construct(
public string $id,
public string $name,
- public null|string $alternative_name,
+ public null|string $alternativeName,
public PuzzleManufacturerResponse $manufacturer,
- public int $pieces_count,
+ public int $piecesCount,
public null|string $image,
public null|string $ean,
- public null|string $identification_number,
- public bool $is_available,
- public bool $is_approved,
+ public null|string $identificationNumber,
+ public bool $isAvailable,
+ public bool $isApproved,
public PuzzleStatisticsResponse $statistics,
public null|PuzzleDifficultyResponse $difficulty,
public null|TimePredictionResponse $prediction,
diff --git a/src/Api/V1/PuzzleSearchResponseProvider.php b/src/Api/V1/PuzzleSearchResponseProvider.php
index 791255af..26e87027 100644
--- a/src/Api/V1/PuzzleSearchResponseProvider.php
+++ b/src/Api/V1/PuzzleSearchResponseProvider.php
@@ -135,7 +135,7 @@ public function provide(Operation $operation, array $uriVariables = [], array $c
total: $total,
page: $page,
limit: $limit,
- has_more: $page * $limit < $total,
+ hasMore: $page * $limit < $total,
puzzles: $puzzles,
);
}
@@ -164,7 +164,7 @@ private function byEan(string $ean, int $page, int $limit, null|Request $request
total: $total,
page: $page,
limit: $limit,
- has_more: $page * $limit < $total,
+ hasMore: $page * $limit < $total,
puzzles: $puzzles,
);
}
diff --git a/src/Api/V1/PuzzleStatisticsGroupResponse.php b/src/Api/V1/PuzzleStatisticsGroupResponse.php
index a13021bb..d8043ff6 100644
--- a/src/Api/V1/PuzzleStatisticsGroupResponse.php
+++ b/src/Api/V1/PuzzleStatisticsGroupResponse.php
@@ -16,10 +16,10 @@ final class PuzzleStatisticsGroupResponse
{
public function __construct(
public int $count,
- public null|int $fastest_seconds,
- public null|int $average_seconds,
- public null|int $slowest_seconds,
- public null|int $median_seconds,
+ public null|int $fastestSeconds,
+ public null|int $averageSeconds,
+ public null|int $slowestSeconds,
+ public null|int $medianSeconds,
) {
}
@@ -27,10 +27,10 @@ public static function fromResult(PuzzleDisciplineStatistics $statistics): self
{
return new self(
count: $statistics->count,
- fastest_seconds: $statistics->fastestSeconds,
- average_seconds: $statistics->averageSeconds,
- slowest_seconds: $statistics->slowestSeconds,
- median_seconds: $statistics->medianSeconds,
+ fastestSeconds: $statistics->fastestSeconds,
+ averageSeconds: $statistics->averageSeconds,
+ slowestSeconds: $statistics->slowestSeconds,
+ medianSeconds: $statistics->medianSeconds,
);
}
}
diff --git a/src/Api/V1/PuzzleStatisticsResponse.php b/src/Api/V1/PuzzleStatisticsResponse.php
index 1857571b..8360e315 100644
--- a/src/Api/V1/PuzzleStatisticsResponse.php
+++ b/src/Api/V1/PuzzleStatisticsResponse.php
@@ -14,7 +14,7 @@
final class PuzzleStatisticsResponse
{
public function __construct(
- public int $solved_times,
+ public int $solvedTimes,
public PuzzleStatisticsGroupResponse $solo,
public PuzzleStatisticsGroupResponse $duo,
public PuzzleStatisticsGroupResponse $team,
@@ -24,7 +24,7 @@ public function __construct(
public static function fromResult(PuzzleStatisticsResult $statistics): self
{
return new self(
- solved_times: $statistics->solvedTimes,
+ solvedTimes: $statistics->solvedTimes,
solo: PuzzleStatisticsGroupResponse::fromResult($statistics->solo),
duo: PuzzleStatisticsGroupResponse::fromResult($statistics->duo),
team: PuzzleStatisticsGroupResponse::fromResult($statistics->team),
diff --git a/src/Api/V1/SellSwapItemResponse.php b/src/Api/V1/SellSwapItemResponse.php
index d0a7edf3..0a6a5ca7 100644
--- a/src/Api/V1/SellSwapItemResponse.php
+++ b/src/Api/V1/SellSwapItemResponse.php
@@ -17,20 +17,20 @@
final class SellSwapItemResponse
{
public function __construct(
- public string $item_id,
- public string $puzzle_id,
- public string $puzzle_name,
- public null|string $manufacturer_name,
- public int $pieces_count,
+ public string $itemId,
+ public string $puzzleId,
+ public string $puzzleName,
+ public null|string $manufacturerName,
+ public int $piecesCount,
public null|string $image,
- public string $listing_type,
+ public string $listingType,
public null|float $price,
public null|string $currency,
public string $condition,
public null|string $comment,
- public bool $is_reserved,
- public bool $is_published_on_marketplace,
- public string $added_at,
+ public bool $isReserved,
+ public bool $isPublishedOnMarketplace,
+ public string $addedAt,
public PuzzleStatisticsResponse $statistics,
public null|PuzzleDifficultyResponse $difficulty,
public null|TimePredictionResponse $prediction,
diff --git a/src/Api/V1/SellSwapResponse.php b/src/Api/V1/SellSwapResponse.php
index 3b43bcaf..c42c6391 100644
--- a/src/Api/V1/SellSwapResponse.php
+++ b/src/Api/V1/SellSwapResponse.php
@@ -59,7 +59,7 @@ final class SellSwapResponse
* @param array $items
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
public int $count,
array $items,
) {
diff --git a/src/Api/V1/SolvesGroupResponse.php b/src/Api/V1/SolvesGroupResponse.php
index d9bc8cd1..d200cb5e 100644
--- a/src/Api/V1/SolvesGroupResponse.php
+++ b/src/Api/V1/SolvesGroupResponse.php
@@ -13,10 +13,10 @@ final class SolvesGroupResponse
{
public function __construct(
public int $count,
- public null|int $best_time_seconds,
- public null|int $last_time_seconds,
- public null|string $first_solved_at,
- public null|string $last_solved_at,
+ public null|int $bestTimeSeconds,
+ public null|int $lastTimeSeconds,
+ public null|string $firstSolvedAt,
+ public null|string $lastSolvedAt,
) {
}
@@ -24,10 +24,10 @@ public static function fromResult(PlayerPuzzleSolvesGroup $group): self
{
return new self(
count: $group->count,
- best_time_seconds: $group->bestTimeSeconds,
- last_time_seconds: $group->lastTimeSeconds,
- first_solved_at: $group->firstSolvedAt?->format('c'),
- last_solved_at: $group->lastSolvedAt?->format('c'),
+ bestTimeSeconds: $group->bestTimeSeconds,
+ lastTimeSeconds: $group->lastTimeSeconds,
+ firstSolvedAt: $group->firstSolvedAt?->format('c'),
+ lastSolvedAt: $group->lastSolvedAt?->format('c'),
);
}
}
diff --git a/src/Api/V1/SolvingTimeResponse.php b/src/Api/V1/SolvingTimeResponse.php
index 02bef1b5..c0b2ab88 100644
--- a/src/Api/V1/SolvingTimeResponse.php
+++ b/src/Api/V1/SolvingTimeResponse.php
@@ -7,14 +7,14 @@
final class SolvingTimeResponse
{
public function __construct(
- public string $time_id,
- public string $puzzle_id,
- public null|int $time_seconds,
- public null|string $finished_at,
- public bool $first_attempt,
+ public string $timeId,
+ public string $puzzleId,
+ public null|int $timeSeconds,
+ public null|string $finishedAt,
+ public bool $firstAttempt,
public bool $unboxed,
public null|string $comment,
- public null|string $round_id = null,
+ public null|string $roundId = null,
/**
* POST only: the time prediction that applied *before* this solve (the one the
* added-time recap page shows) - solo times, token owner a member who has not
diff --git a/src/Api/V1/StatisticsGroupResponse.php b/src/Api/V1/StatisticsGroupResponse.php
index dad19776..bc43a896 100644
--- a/src/Api/V1/StatisticsGroupResponse.php
+++ b/src/Api/V1/StatisticsGroupResponse.php
@@ -7,9 +7,9 @@
final class StatisticsGroupResponse
{
public function __construct(
- public int $total_seconds,
- public int $total_pieces,
- public int $solved_puzzles_count,
+ public int $totalSeconds,
+ public int $totalPieces,
+ public int $solvedPuzzlesCount,
) {
}
}
diff --git a/src/Api/V1/TimePredictionResponse.php b/src/Api/V1/TimePredictionResponse.php
index d78b14e9..16c48c0b 100644
--- a/src/Api/V1/TimePredictionResponse.php
+++ b/src/Api/V1/TimePredictionResponse.php
@@ -16,26 +16,26 @@
final class TimePredictionResponse
{
public function __construct(
- public null|int $predicted_seconds,
- public null|int $range_low_seconds,
- public null|int $range_high_seconds,
- public bool $is_personalized,
- public null|int $personal_solve_count,
- public null|int $predicted_attempt_number,
- public null|int $last_time_seconds,
+ public null|int $predictedSeconds,
+ public null|int $rangeLowSeconds,
+ public null|int $rangeHighSeconds,
+ public bool $isPersonalized,
+ public null|int $personalSolveCount,
+ public null|int $predictedAttemptNumber,
+ public null|int $lastTimeSeconds,
) {
}
public static function fromResult(null|TimePredictionResult $prediction): self
{
return new self(
- predicted_seconds: $prediction?->predictedSeconds,
- range_low_seconds: $prediction?->rangeLowSeconds,
- range_high_seconds: $prediction?->rangeHighSeconds,
- is_personalized: $prediction !== null && $prediction->isPersonalized,
- personal_solve_count: $prediction?->personalSolveCount,
- predicted_attempt_number: $prediction?->predictedAttemptNumber,
- last_time_seconds: $prediction?->lastTimeSeconds,
+ predictedSeconds: $prediction?->predictedSeconds,
+ rangeLowSeconds: $prediction?->rangeLowSeconds,
+ rangeHighSeconds: $prediction?->rangeHighSeconds,
+ isPersonalized: $prediction !== null && $prediction->isPersonalized,
+ personalSolveCount: $prediction?->personalSolveCount,
+ predictedAttemptNumber: $prediction?->predictedAttemptNumber,
+ lastTimeSeconds: $prediction?->lastTimeSeconds,
);
}
}
diff --git a/src/Api/V1/UnsolvedPuzzleResponse.php b/src/Api/V1/UnsolvedPuzzleResponse.php
index 5d5111b8..7ebb1cc6 100644
--- a/src/Api/V1/UnsolvedPuzzleResponse.php
+++ b/src/Api/V1/UnsolvedPuzzleResponse.php
@@ -14,13 +14,13 @@
final class UnsolvedPuzzleResponse
{
public function __construct(
- public string $puzzle_id,
- public string $puzzle_name,
- public null|string $manufacturer_name,
- public int $pieces_count,
+ public string $puzzleId,
+ public string $puzzleName,
+ public null|string $manufacturerName,
+ public int $piecesCount,
public null|string $image,
- public string $added_at,
- public bool $is_borrowed,
+ public string $addedAt,
+ public bool $isBorrowed,
public PuzzleStatisticsResponse $statistics,
public null|PuzzleDifficultyResponse $difficulty,
public null|TimePredictionResponse $prediction,
diff --git a/src/Api/V1/UnsolvedPuzzlesResponse.php b/src/Api/V1/UnsolvedPuzzlesResponse.php
index 4ad43a4f..90ee2697 100644
--- a/src/Api/V1/UnsolvedPuzzlesResponse.php
+++ b/src/Api/V1/UnsolvedPuzzlesResponse.php
@@ -61,7 +61,7 @@ final class UnsolvedPuzzlesResponse
* @param array $items
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
public int $count,
array $items,
) {
diff --git a/src/Api/V1/UpdateCollectionProcessor.php b/src/Api/V1/UpdateCollectionProcessor.php
index 8dbd35cf..20a372e2 100644
--- a/src/Api/V1/UpdateCollectionProcessor.php
+++ b/src/Api/V1/UpdateCollectionProcessor.php
@@ -73,7 +73,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
);
return new CollectionResponse(
- collection_id: $collectionId,
+ collectionId: $collectionId,
name: $data->name,
description: $data->description,
visibility: $visibility->value,
diff --git a/src/Api/V1/UpdateSolvingTimeInput.php b/src/Api/V1/UpdateSolvingTimeInput.php
index 22831953..7ed423e9 100644
--- a/src/Api/V1/UpdateSolvingTimeInput.php
+++ b/src/Api/V1/UpdateSolvingTimeInput.php
@@ -31,12 +31,12 @@ final class UpdateSolvingTimeInput
public null|string $comment = null;
- public null|string $finished_at = null;
+ public null|string $finishedAt = null;
- public bool $first_attempt = false;
+ public bool $firstAttempt = false;
public bool $unboxed = false;
/** @var array */
- public array $group_players = [];
+ public array $groupPlayers = [];
}
diff --git a/src/Api/V1/UpdateSolvingTimeProcessor.php b/src/Api/V1/UpdateSolvingTimeProcessor.php
index 328e18f7..9fdc12e7 100644
--- a/src/Api/V1/UpdateSolvingTimeProcessor.php
+++ b/src/Api/V1/UpdateSolvingTimeProcessor.php
@@ -55,7 +55,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
throw new AccessDeniedHttpException('Player account has no linked user login.');
}
- $finishedAt = $data->finished_at !== null ? new DateTimeImmutable($data->finished_at) : null;
+ $finishedAt = $data->finishedAt !== null ? new DateTimeImmutable($data->finishedAt) : null;
$this->messageBus->dispatch(
new EditPuzzleSolvingTime(
@@ -64,20 +64,20 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
competitionId: null,
time: $data->time,
comment: $data->comment,
- groupPlayers: $data->group_players,
+ groupPlayers: $data->groupPlayers,
finishedAt: $finishedAt,
finishedPuzzlesPhoto: null,
- firstAttempt: $data->first_attempt,
+ firstAttempt: $data->firstAttempt,
unboxed: $data->unboxed,
),
);
return new SolvingTimeResponse(
- time_id: $timeId,
- puzzle_id: $solvingTime->puzzle->id->toString(),
- time_seconds: null,
- finished_at: $finishedAt?->format('c'),
- first_attempt: $data->first_attempt,
+ timeId: $timeId,
+ puzzleId: $solvingTime->puzzle->id->toString(),
+ timeSeconds: null,
+ finishedAt: $finishedAt?->format('c'),
+ firstAttempt: $data->firstAttempt,
unboxed: $data->unboxed,
comment: $data->comment,
);
diff --git a/src/Api/V1/WishlistItemResponse.php b/src/Api/V1/WishlistItemResponse.php
index d3aebed1..0385d646 100644
--- a/src/Api/V1/WishlistItemResponse.php
+++ b/src/Api/V1/WishlistItemResponse.php
@@ -17,13 +17,13 @@
final class WishlistItemResponse
{
public function __construct(
- public string $wishlist_item_id,
- public string $puzzle_id,
- public string $puzzle_name,
- public null|string $manufacturer_name,
- public int $pieces_count,
+ public string $wishlistItemId,
+ public string $puzzleId,
+ public string $puzzleName,
+ public null|string $manufacturerName,
+ public int $piecesCount,
public null|string $image,
- public string $added_at,
+ public string $addedAt,
public PuzzleStatisticsResponse $statistics,
public null|PuzzleDifficultyResponse $difficulty,
public null|TimePredictionResponse $prediction,
diff --git a/src/Api/V1/WishlistResponse.php b/src/Api/V1/WishlistResponse.php
index d85b5707..fd594556 100644
--- a/src/Api/V1/WishlistResponse.php
+++ b/src/Api/V1/WishlistResponse.php
@@ -55,7 +55,7 @@ final class WishlistResponse
* @param array $items
*/
public function __construct(
- public string $player_id,
+ public string $playerId,
public int $count,
array $items,
) {
diff --git a/src/Services/Api/ApiDtoNormalizer.php b/src/Services/Api/ApiDtoNormalizer.php
new file mode 100644
index 00000000..928d7964
--- /dev/null
+++ b/src/Services/Api/ApiDtoNormalizer.php
@@ -0,0 +1,103 @@
+> */
+ private array $properties = [];
+
+ public function __construct(
+ private readonly NameConverterInterface $nameConverter,
+ private readonly ResourceClassResolverInterface $resourceClassResolver,
+ ) {
+ }
+
+ public function reset(): void
+ {
+ $this->properties = [];
+ }
+
+ /**
+ * @param array $context
+ *
+ * @return array
+ */
+ public function normalize(mixed $data, null|string $format = null, array $context = []): array
+ {
+ assert(is_object($data));
+
+ $normalized = [];
+
+ foreach ($this->publicProperties($data::class) as $property) {
+ $value = $property->getValue($data);
+
+ if (is_object($value) || is_array($value)) {
+ $value = $this->normalizer->normalize($value, $format, $context);
+ }
+
+ $normalized[$this->nameConverter->normalize($property->getName(), $data::class, $format, $context)] = $value;
+ }
+
+ return $normalized;
+ }
+
+ /**
+ * @param array $context
+ */
+ public function supportsNormalization(mixed $data, null|string $format = null, array $context = []): bool
+ {
+ return is_object($data)
+ && str_starts_with($data::class, self::NAMESPACE_PREFIX)
+ && $this->resourceClassResolver->isResourceClass($data::class) === false;
+ }
+
+ /**
+ * @return array
+ */
+ public function getSupportedTypes(null|string $format): array
+ {
+ return ['object' => false];
+ }
+
+ /**
+ * @param class-string $class
+ *
+ * @return list
+ */
+ private function publicProperties(string $class): array
+ {
+ return $this->properties[$class] ??= array_values(array_filter(
+ (new ReflectionClass($class))->getProperties(ReflectionProperty::IS_PUBLIC),
+ static fn (ReflectionProperty $property): bool => $property->isStatic() === false,
+ ));
+ }
+}
diff --git a/src/Services/Api/PuzzleLibraryItemsFactory.php b/src/Services/Api/PuzzleLibraryItemsFactory.php
index 8ed6b77c..9c2a446f 100644
--- a/src/Services/Api/PuzzleLibraryItemsFactory.php
+++ b/src/Services/Api/PuzzleLibraryItemsFactory.php
@@ -61,13 +61,13 @@ public function wishlist(string $ownerPlayerId): array
return array_values(array_map(
static fn (WishListItemOverview $item): WishlistItemResponse => new WishlistItemResponse(
- wishlist_item_id: $item->wishListItemId,
- puzzle_id: $item->puzzleId,
- puzzle_name: $item->puzzleName,
- manufacturer_name: $item->manufacturerName,
- pieces_count: $item->piecesCount,
+ wishlistItemId: $item->wishListItemId,
+ puzzleId: $item->puzzleId,
+ puzzleName: $item->puzzleName,
+ manufacturerName: $item->manufacturerName,
+ piecesCount: $item->piecesCount,
image: $item->image,
- added_at: $item->addedAt->format('c'),
+ addedAt: $item->addedAt->format('c'),
statistics: $insights->statistics($item->puzzleId),
difficulty: $insights->difficulty($item->puzzleId),
prediction: $insights->prediction($item->puzzleId),
@@ -97,13 +97,13 @@ public function unsolvedPuzzles(string $ownerPlayerId): array
return array_values(array_map(
static fn (UnsolvedPuzzleItem $item): UnsolvedPuzzleResponse => new UnsolvedPuzzleResponse(
- puzzle_id: $item->puzzleId,
- puzzle_name: $item->puzzleName,
- manufacturer_name: $item->manufacturerName,
- pieces_count: $item->piecesCount,
+ puzzleId: $item->puzzleId,
+ puzzleName: $item->puzzleName,
+ manufacturerName: $item->manufacturerName,
+ piecesCount: $item->piecesCount,
image: $item->image,
- added_at: $item->addedAt->format('c'),
- is_borrowed: $item->isBorrowed,
+ addedAt: $item->addedAt->format('c'),
+ isBorrowed: $item->isBorrowed,
statistics: $insights->statistics($item->puzzleId),
difficulty: $insights->difficulty($item->puzzleId),
prediction: $insights->prediction($item->puzzleId),
@@ -136,18 +136,18 @@ public function lendBorrow(string $ownerPlayerId): array
foreach ($lent as $item) {
$items[] = new LentPuzzleResponse(
- lent_puzzle_id: $item->lentPuzzleId,
+ lentPuzzleId: $item->lentPuzzleId,
direction: LentPuzzleResponse::DIRECTION_LENT,
- puzzle_id: $item->puzzleId,
- puzzle_name: $item->puzzleName,
- manufacturer_name: $item->manufacturerName,
- pieces_count: $item->piecesCount,
+ puzzleId: $item->puzzleId,
+ puzzleName: $item->puzzleName,
+ manufacturerName: $item->manufacturerName,
+ piecesCount: $item->piecesCount,
image: $item->image,
counterparty: new LentPuzzleCounterpartyResponse(
- player_id: $item->currentHolderId,
+ playerId: $item->currentHolderId,
name: $item->currentHolderName,
),
- lent_at: $item->lentAt->format('c'),
+ lentAt: $item->lentAt->format('c'),
notes: $item->notes,
statistics: $insights->statistics($item->puzzleId),
difficulty: $insights->difficulty($item->puzzleId),
@@ -158,18 +158,18 @@ public function lendBorrow(string $ownerPlayerId): array
foreach ($borrowed as $item) {
$items[] = new LentPuzzleResponse(
- lent_puzzle_id: $item->lentPuzzleId,
+ lentPuzzleId: $item->lentPuzzleId,
direction: LentPuzzleResponse::DIRECTION_BORROWED,
- puzzle_id: $item->puzzleId,
- puzzle_name: $item->puzzleName,
- manufacturer_name: $item->manufacturerName,
- pieces_count: $item->piecesCount,
+ puzzleId: $item->puzzleId,
+ puzzleName: $item->puzzleName,
+ manufacturerName: $item->manufacturerName,
+ piecesCount: $item->piecesCount,
image: $item->image,
counterparty: new LentPuzzleCounterpartyResponse(
- player_id: $item->ownerId,
+ playerId: $item->ownerId,
name: $item->ownerName,
),
- lent_at: $item->lentAt->format('c'),
+ lentAt: $item->lentAt->format('c'),
notes: $item->notes,
statistics: $insights->statistics($item->puzzleId),
difficulty: $insights->difficulty($item->puzzleId),
@@ -202,20 +202,20 @@ public function sellSwap(PlayerProfile $owner): array
return array_values(array_map(
static fn (SellSwapListItemOverview $item): SellSwapItemResponse => new SellSwapItemResponse(
- item_id: $item->sellSwapListItemId,
- puzzle_id: $item->puzzleId,
- puzzle_name: $item->puzzleName,
- manufacturer_name: $item->manufacturerName,
- pieces_count: $item->piecesCount,
+ itemId: $item->sellSwapListItemId,
+ puzzleId: $item->puzzleId,
+ puzzleName: $item->puzzleName,
+ manufacturerName: $item->manufacturerName,
+ piecesCount: $item->piecesCount,
image: $item->image,
- listing_type: $item->listingType->value,
+ listingType: $item->listingType->value,
price: $item->price,
currency: $item->price !== null ? $currency : null,
condition: $item->condition->value,
comment: $item->comment,
- is_reserved: $item->reserved,
- is_published_on_marketplace: $item->publishedOnMarketplace,
- added_at: $item->addedAt->format('c'),
+ isReserved: $item->reserved,
+ isPublishedOnMarketplace: $item->publishedOnMarketplace,
+ addedAt: $item->addedAt->format('c'),
statistics: $insights->statistics($item->puzzleId),
difficulty: $insights->difficulty($item->puzzleId),
prediction: $insights->prediction($item->puzzleId),
diff --git a/src/Services/Api/PuzzleLibrarySummaryFactory.php b/src/Services/Api/PuzzleLibrarySummaryFactory.php
index c822d67d..df3a1305 100644
--- a/src/Services/Api/PuzzleLibrarySummaryFactory.php
+++ b/src/Services/Api/PuzzleLibrarySummaryFactory.php
@@ -58,7 +58,7 @@ public function summary(PlayerProfile $owner): LibraryResponse
}
return new LibraryResponse(
- player_id: $playerId,
+ playerId: $playerId,
collections: $this->collections($owner),
unsolved: new LibrarySectionResponse(
count: $this->visibility->isVisibleToTokenOwner($owner, $owner->unsolvedPuzzlesVisibility)
@@ -72,13 +72,13 @@ public function summary(PlayerProfile $owner): LibraryResponse
: 0,
visibility: $this->visibility->reportedVisibility($owner, $owner->wishListVisibility),
),
- lend_borrow: new LibraryLendBorrowSectionResponse(
- lent_count: $lentCount,
- borrowed_count: $borrowedCount,
+ lendBorrow: new LibraryLendBorrowSectionResponse(
+ lentCount: $lentCount,
+ borrowedCount: $borrowedCount,
visibility: $this->visibility->reportedVisibility($owner, $owner->lendBorrowListVisibility),
),
// always public on the website - only a private profile hides it
- sell_swap: new LibrarySellSwapSectionResponse(
+ sellSwap: new LibrarySellSwapSectionResponse(
count: $this->visibility->isVisibleToTokenOwner($owner, CollectionVisibility::Public)
? $this->getSellSwapListItems->countByPlayerId($playerId)
: 0,
@@ -107,21 +107,21 @@ private function collections(PlayerProfile $owner): array
if ($this->visibility->isVisibleToTokenOwner($owner, $owner->puzzleCollectionVisibility)) {
$collections[] = new LibraryCollectionResponse(
- collection_id: 'default',
+ collectionId: 'default',
name: self::SYSTEM_COLLECTION_NAME,
description: null,
visibility: $owner->puzzleCollectionVisibility->value,
- item_count: $this->getPlayerCollectionsWithCounts->countSystemCollection($owner->playerId),
+ itemCount: $this->getPlayerCollectionsWithCounts->countSystemCollection($owner->playerId),
);
}
foreach ($this->getPlayerCollectionsWithCounts->byPlayerId($owner->playerId, includePrivate: $isOwner) as $collection) {
$collections[] = new LibraryCollectionResponse(
- collection_id: $collection->collectionId ?? 'default',
+ collectionId: $collection->collectionId ?? 'default',
name: $collection->name,
description: $collection->description,
visibility: $collection->visibility->value,
- item_count: $collection->itemCount,
+ itemCount: $collection->itemCount,
);
}
diff --git a/src/Services/Api/PuzzleResponseFactory.php b/src/Services/Api/PuzzleResponseFactory.php
index f345fda4..d4b5af5b 100644
--- a/src/Services/Api/PuzzleResponseFactory.php
+++ b/src/Services/Api/PuzzleResponseFactory.php
@@ -116,17 +116,17 @@ public function cards(array $overviews): array
$cards[] = new PuzzleResponse(
id: $puzzleId,
name: $overview->puzzleName,
- alternative_name: $overview->puzzleAlternativeName,
+ alternativeName: $overview->puzzleAlternativeName,
manufacturer: new PuzzleManufacturerResponse(
id: $overview->manufacturerId,
name: $overview->manufacturerName,
),
- pieces_count: $overview->piecesCount,
+ piecesCount: $overview->piecesCount,
image: $overview->puzzleImage,
ean: $overview->puzzleEan,
- identification_number: $overview->puzzleIdentificationNumber,
- is_available: $overview->isAvailable,
- is_approved: $overview->puzzleApproved,
+ identificationNumber: $overview->puzzleIdentificationNumber,
+ isAvailable: $overview->isAvailable,
+ isApproved: $overview->puzzleApproved,
statistics: $insights->statistics($puzzleId),
difficulty: $insights->difficulty($puzzleId),
prediction: $insights->prediction($puzzleId),