Skip to content

Commit

Permalink
Allow int in endpoint identifier version (#148)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Beranek <[email protected]>
  • Loading branch information
Martin-Beranek and Martin Beranek authored May 14, 2024
1 parent 7d99bb7 commit 69e2be3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## [Unreleased][unreleased]
#### Changed
* [BC] Support for semantic versioning api. Need retype version from `int` to `string`.
* Support for semantic versioning api.
* [BC] DefaultHandler response code 404 instead 400

#### Added
Expand Down
9 changes: 8 additions & 1 deletion src/EndpointIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ class EndpointIdentifier implements EndpointInterface

private $apiAction;

public function __construct(string $method, string $version, string $package, ?string $apiAction = null)
/**
* @param string $method example: "GET", "POST", "PUT", "DELETE"
* @param string|int $version Version must have semantic numbering. For example "1", "1.1", "0.13.2" etc.
* @param string $package example: "users"
* @param string|null $apiAction example: "query"
*/
public function __construct(string $method, $version, string $package, ?string $apiAction = null)
{
$version = (string) $version;
$this->method = strtoupper($method);
if (strpos($version, '/') !== false) {
throw new InvalidArgumentException('Version must have semantic numbering. For example "1", "1.1", "0.13.2" etc.');
Expand Down

0 comments on commit 69e2be3

Please sign in to comment.