From 69e2be31b34667f07c345fe1d2e598d3fc91bf82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ber=C3=A1nek?= Date: Tue, 14 May 2024 10:00:10 +0200 Subject: [PATCH] Allow int in endpoint identifier version (#148) Co-authored-by: Martin Beranek --- CHANGELOG.md | 2 +- src/EndpointIdentifier.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2cdc4a..3eb7cf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/EndpointIdentifier.php b/src/EndpointIdentifier.php index e91a102..43fae40 100644 --- a/src/EndpointIdentifier.php +++ b/src/EndpointIdentifier.php @@ -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.');