1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace RestTemplate\Util; |
5
|
|
|
|
6
|
|
|
use Builder\Psr11; |
7
|
|
|
use ByJG\ApiTools\AbstractRequester; |
8
|
|
|
use ByJG\Config\Exception\ConfigNotFoundException; |
9
|
|
|
use ByJG\Config\Exception\EnvironmentException; |
10
|
|
|
use ByJG\Config\Exception\KeyNotFoundException; |
11
|
|
|
use ByJG\RestServer\Exception\ClassNotFoundException; |
12
|
|
|
use ByJG\RestServer\Exception\Error404Exception; |
13
|
|
|
use ByJG\RestServer\Exception\Error405Exception; |
14
|
|
|
use ByJG\RestServer\Exception\Error520Exception; |
15
|
|
|
use ByJG\RestServer\Exception\InvalidClassException; |
16
|
|
|
use ByJG\RestServer\MockRequestHandler; |
17
|
|
|
use ByJG\RestServer\Route\OpenApiRouteDefinition; |
18
|
|
|
use ByJG\Util\Psr7\MessageException; |
19
|
|
|
use ByJG\Util\Psr7\Response; |
20
|
|
|
use Psr\Http\Message\RequestInterface; |
21
|
|
|
use Psr\Http\Message\ResponseInterface; |
22
|
|
|
use Psr\SimpleCache\InvalidArgumentException; |
23
|
|
|
use ReflectionException; |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Request handler based on ByJG HttpClient (WebRequest) . |
28
|
|
|
*/ |
29
|
|
|
class FakeApiRequester extends AbstractRequester |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @param RequestInterface $request |
33
|
|
|
* @return Response|ResponseInterface |
34
|
|
|
* @throws MessageException |
35
|
|
|
* @throws ConfigNotFoundException |
36
|
|
|
* @throws EnvironmentException |
37
|
|
|
* @throws KeyNotFoundException |
38
|
|
|
* @throws ClassNotFoundException |
39
|
|
|
* @throws Error404Exception |
40
|
|
|
* @throws Error405Exception |
41
|
|
|
* @throws Error520Exception |
42
|
|
|
* @throws InvalidClassException |
43
|
|
|
* @throws InvalidArgumentException |
44
|
|
|
* @throws ReflectionException |
45
|
|
|
*/ |
46
|
|
|
protected function handleRequest(RequestInterface $request) |
47
|
|
|
{ |
48
|
|
|
return MockRequestHandler::mock(Psr11::container()->get(OpenApiRouteDefinition::class), $request); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|