From 5d5bbfd5ab01092b48336fbd065008db6619b7c2 Mon Sep 17 00:00:00 2001 From: Marcel Frankruijter <8653925+mfrankruijter@users.noreply.github.com> Date: Fri, 22 Mar 2019 12:52:26 +0100 Subject: [PATCH] 2.0.0 ## 2.0.0 - 2019-03-22 ### Added - Added parameters to the Request interface and implementation. ### Changed - Order of constructor parameters - Default value of the request method. ### Removed - SearchCriteria dependency by expecting GET parameters as an associative array. --- CHANGELOG.md | 24 +++++++++++++++++++++- README.md | 21 ++++++++++---------- composer.json | 3 +-- src/Common/RequestInterface.php | 8 +++----- src/Transaction/Request.php | 33 +++++++++++++++---------------- tests/Transaction/RequestTest.php | 10 ++++------ 6 files changed, 58 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d49932a..e43c539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,27 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 2.0.0 - 2019-03-22 +### Added +- Added parameters to the Request interface and implementation. + +### Changed +- Order of constructor parameters +- Default value of the request method. + +### Deprecated +- Nothing + +### Removed +- SearchCriteria dependency by expecting GET parameters as an associative array. + +### Fixed +- Nothing + +### Security +- Nothing + + ## 1.0.0 - 2019-03-05 ### Added - Initial implementation of ulrack/transaction @@ -29,4 +50,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security - Nothing -[Unreleased]: https://github.com/ulrack/transaction/compare/1.0.0...HEAD +[Unreleased]: https://github.com/ulrack/transaction/compare/2.0.0...HEAD +[1.0.0]: https://github.com/ulrack/transaction/compare/1.0.0...2.0.0 diff --git a/README.md b/README.md index 21be012..f96eb48 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,14 @@ The implementation of a `\Ulrack\Transaction\Common\RequestInterface` is provide in `\Ulrack\Transaction\Transaction\Request`. Requests expect their arguments in the constructor. -The first argument expects a method. This method can be picked from the + +The first argument expects a target for the request. +In the case of a HTTP request this would the URI for the request. + +The second argument is the payload of the request. +The payload would be the body of a request, in the case of a HTTP POST request, this would be the form data. + +The third argument expects a method. This method can be picked from the `\Ulrack\Transaction\Common\RequestInterface` and should be one of: - `RequestInterface::METHOD_GET` - `RequestInterface::METHOD_POST` @@ -30,16 +37,10 @@ The first argument expects a method. This method can be picked from the - `RequestInterface::METHOD_PATCH` - `RequestInterface::METHOD_DELETE` -The second argument expects a target for the request. -In the case of a HTTP request this would the URI for the request. - -The third argument is the payload of the request. -The payload would be the body of a request, in the case of a HTTP POST request, this would be the form data. - -The fourth argument is optional and expects an associative array with headers. +The fourth argument is optional and expects an associative array with parameters. +In the case of a HTTP request, this expects the GET parameters. -The fifth argument is also optional and expects a `SearchCriteriaInterface` object. -In the case of a HTTP GET request this would be cause the GET parameters to be filled. +The fifth argument is optional and expects an associative array with headers. ### Response diff --git a/composer.json b/composer.json index 35d6f6a..ff94c68 100644 --- a/composer.json +++ b/composer.json @@ -7,8 +7,7 @@ "prefer-stable": true, "minimum-stability": "stable", "require": { - "php": "^7.2", - "ulrack/search": "^1.0" + "php": "^7.2" }, "authors": [ { diff --git a/src/Common/RequestInterface.php b/src/Common/RequestInterface.php index 9b3a1cf..57f57a2 100644 --- a/src/Common/RequestInterface.php +++ b/src/Common/RequestInterface.php @@ -6,8 +6,6 @@ namespace Ulrack\Transaction\Common; -use Ulrack\Search\Common\SearchCriteriaInterface; - interface RequestInterface { /** @@ -88,9 +86,9 @@ public function getTarget(): string; public function getPayload(); /** - * Retrieves the search criteria for the request. + * Retrieves a associative array of parameters of the request. * - * @return SearchCriteriaInterface|null + * @return array|null */ - public function getSearchCriteria(): ?SearchCriteriaInterface; + public function getParameters(): ?array; } diff --git a/src/Transaction/Request.php b/src/Transaction/Request.php index 0765a1f..2af5b91 100644 --- a/src/Transaction/Request.php +++ b/src/Transaction/Request.php @@ -8,7 +8,6 @@ use Ulrack\Transaction\Common\RequestInterface; use Ulrack\Transaction\Exception\HeaderNotFoundException; -use Ulrack\Search\Common\SearchCriteriaInterface; class Request implements RequestInterface { @@ -24,30 +23,30 @@ class Request implements RequestInterface /** @var mixed */ private $payload; - /** @var SearchCriteriaInterface|null */ - private $searchCriteria; + /** @var array|null */ + private $parameters; /** * Constructor * - * @param string $method - * @param string $target - * @param mixed $payload - * @param array|null $headers - * @param SearchCriteriaInterface|null $searchCriteria + * @param string $target + * @param mixed $payload + * @param array $parameters + * @param string $method + * @param array|null $headers */ public function __construct( - string $method, string $target, $payload, + string $method = RequestInterface::METHOD_GET, array $headers = null, - SearchCriteriaInterface $searchCriteria = null + array $parameters = null ) { - $this->method = $method; - $this->headers = $headers; $this->target = $target; $this->payload = $payload; - $this->searchCriteria = $searchCriteria; + $this->method = $method; + $this->headers = $headers; + $this->parameters = $parameters; } /** @@ -109,12 +108,12 @@ public function getPayload() } /** - * Retrieves the search criteria for the request. + * Retrieves a associative array of parameters of the request. * - * @return SearchCriteriaInterface|null + * @return array|null */ - public function getSearchCriteria(): ?SearchCriteriaInterface + public function getParameters(): ?array { - return $this->searchCriteria; + return $this->parameters; } } diff --git a/tests/Transaction/RequestTest.php b/tests/Transaction/RequestTest.php index 95f1eb9..6698795 100644 --- a/tests/Transaction/RequestTest.php +++ b/tests/Transaction/RequestTest.php @@ -9,7 +9,6 @@ use PHPUnit\Framework\TestCase; use Ulrack\Transaction\Transaction\Request; use Ulrack\Transaction\Common\RequestInterface; -use Ulrack\Search\Common\SearchCriteriaInterface; use Ulrack\Transaction\Exception\HeaderNotFoundException; /** @@ -27,17 +26,16 @@ class RequestTest extends TestCase * @covers ::getHeader * @covers ::getTarget * @covers ::getPayload - * @covers ::getSearchCriteria + * @covers ::getParameters */ public function testRequest(): void { - $searchCriteria = $this->createMock(SearchCriteriaInterface::class); $subject = new Request( - RequestInterface::METHOD_GET, 'foo', ['bar' => 'baz'], + RequestInterface::METHOD_GET, ['baz' => 'qux'], - $searchCriteria + ['foo' => 'bar'] ); $this->assertInstanceOf(Request::class, $subject); @@ -46,7 +44,7 @@ public function testRequest(): void $this->assertEquals('qux', $subject->getHeader('baz')); $this->assertEquals('foo', $subject->getTarget()); $this->assertEquals(['bar' => 'baz'], $subject->getPayload()); - $this->assertEquals($searchCriteria, $subject->getSearchCriteria()); + $this->assertEquals(['foo' => 'bar'], $subject->getParameters()); $this->expectException(HeaderNotFoundException::class); $subject->getHeader('foo'); }