Skip to content

Coordinate can have strings as values #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/Tests export-ignore
/phpunit.xml export-ignore
/.php_cs export-ignore
/.formatter.yml export-ignore
/.circleci export-ignore
/.editorconfig export-ignore
4 changes: 2 additions & 2 deletions Exception/TooManyRequestsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace Apisearch\Exception;

/**
* Class TooManyRequestsException
* Class TooManyRequestsException.
*/
class TooManyRequestsException extends TransportableException
{
Expand All @@ -39,4 +39,4 @@ public static function tooManyRequestsReached(): self
{
return new self('You reached the rate limit. Please, check your permissions');
}
}
}
4 changes: 2 additions & 2 deletions Http/HttpResponsesToException.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ protected static function throwTransportableExceptionIfNeeded(
throw new ResourceExistsException($response['body']['message']);
case ForbiddenException::getTransportableHTTPError():
throw new ForbiddenException($response['body']['message']);
case TooManyRequestsException::getTransportableHTTPError();
case TooManyRequestsException::getTransportableHTTPError():
throw new TooManyRequestsException($response['body']['message']);
case ConnectionException::getTransportableHTTPError():
throw new ConnectionException('Apisearch returned an internal error code [500] - ' . $response['body']['message']);
throw new ConnectionException('Apisearch returned an internal error code [500] - '.$response['body']['message']);
}
}
}
4 changes: 2 additions & 2 deletions Model/Coordinate.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public static function createFromArray(array $array): self
}

return new self(
$array['lat'],
$array['lon']
\floatval($array['lat']),
\floatval($array['lon'])
);
}
}
19 changes: 19 additions & 0 deletions Tests/Model/CoordinateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,23 @@ public function testToArray()
$coordinate->toArray()
);
}

/**
* Test string values.
*/
public function testAsString()
{
$coordinateAsArray = [
'lat' => '1.20',
'lon' => '2.10',
];
$coordinate = Coordinate::createFromArray($coordinateAsArray);
$this->assertEquals(
[
'lat' => 1.20,
'lon' => 2.10,
],
$coordinate->toArray()
);
}
}