Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Commit

Permalink
Fix code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Dec 29, 2020
1 parent 3179699 commit a02323f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 34 deletions.
19 changes: 16 additions & 3 deletions src/Dynamap.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(DynamoDbClient $dynamoDb, array $mapping)

public static function fromOptions(array $options, array $mapping): self
{
$options['version'] = $options['version'] ?? 'latest';
$options['version'] ??= 'latest';

return new static(new DynamoDbClient($options), $mapping);
}
Expand All @@ -37,6 +37,11 @@ public function getTable(string $className): Table
return $this->tables[$className];
}

/**
* @template T
* @param class-string<T> $class
* @return T[]
*/
public function getAll(string $class): array
{
return $this->getTable($class)->getAll();
Expand All @@ -47,10 +52,14 @@ public function getAll(string $class): array
*
* Throws an exception if the item cannot be found (see `find()` as an alternative).
*
* @template T
* @param class-string<T> $class
* @return T
*
* @throws InvalidArgumentException If the key is invalid.
* @throws ItemNotFound If the item cannot be found.
*/
public function get(string $class, array|int|string $key): object
public function get(string $class, array | int | string $key): object
{
return $this->getTable($class)->get($key);
}
Expand All @@ -60,9 +69,13 @@ public function get(string $class, array|int|string $key): object
*
* Returns null if the item cannot be found (see `get()` as an alternative).
*
* @template T
* @param class-string<T> $class
* @return T|null
*
* @throws InvalidArgumentException If the key is invalid.
*/
public function find(string $class, array|int|string $key): ?object
public function find(string $class, array | int | string $key): ?object
{
return $this->getTable($class)->find($key);
}
Expand Down
6 changes: 0 additions & 6 deletions src/Field/BooleanField.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@ public function dynamoDbType(): string
return 'BOOL';
}

/**
* {@inheritdoc}
*/
protected function castValueForDynamoDbFormat(mixed $value): bool
{
return (bool) $value;
}

/**
* {@inheritdoc}
*/
protected function castValueFromDynamoDbFormat(mixed $value): bool
{
return (bool) $value;
Expand Down
6 changes: 0 additions & 6 deletions src/Field/DateTimeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ public function dynamoDbType(): string
return 'S';
}

/**
* {@inheritdoc}
*/
protected function castValueForDynamoDbFormat(mixed $value): string
{
if (! $value instanceof DateTimeInterface) {
Expand All @@ -24,9 +21,6 @@ protected function castValueForDynamoDbFormat(mixed $value): string
return $value->format(DateTimeInterface::ATOM);
}

/**
* {@inheritdoc}
*/
protected function castValueFromDynamoDbFormat(mixed $value): DateTimeInterface
{
return \DateTimeImmutable::createFromFormat(DateTimeInterface::ATOM, $value);
Expand Down
6 changes: 0 additions & 6 deletions src/Field/FloatField.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ public function dynamoDbType(): string
return 'N';
}

/**
* {@inheritdoc}
*/
protected function castValueForDynamoDbFormat(mixed $value): string
{
// Numbers should be sent as strings to DynamoDB
return (string) $value;
}

/**
* {@inheritdoc}
*/
protected function castValueFromDynamoDbFormat(mixed $value): float
{
return (float) $value;
Expand Down
6 changes: 0 additions & 6 deletions src/Field/IntegerField.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ public function dynamoDbType(): string
return 'N';
}

/**
* {@inheritdoc}
*/
protected function castValueForDynamoDbFormat(mixed $value): string
{
// Numbers should be sent as strings to DynamoDB
return (string) $value;
}

/**
* {@inheritdoc}
*/
protected function castValueFromDynamoDbFormat(mixed $value): int
{
return (int) $value;
Expand Down
6 changes: 0 additions & 6 deletions src/Field/StringField.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@ public function dynamoDbType(): string
return 'S';
}

/**
* {@inheritdoc}
*/
protected function castValueForDynamoDbFormat(mixed $value): string
{
return (string) $value;
}

/**
* {@inheritdoc}
*/
protected function castValueFromDynamoDbFormat(mixed $value): string
{
return (string) $value;
Expand Down
2 changes: 1 addition & 1 deletion src/TableMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private function readProperties(string $className, array $keys): void
$property = $propertyReflection->getName();
$propertyType = $propertyReflection->getType();

if (!$propertyType) {
if (! $propertyType) {
$propertyTypes = $this->propertyInfo->getTypes($className, $property);
if (empty($propertyTypes)) {
throw new \Exception("Type not recognized for {$className}::\${$property}");
Expand Down

0 comments on commit a02323f

Please sign in to comment.