|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of Flight Routing. |
|
7
|
|
|
* |
|
8
|
|
|
* PHP version 7.2 and above required |
|
9
|
|
|
* |
|
10
|
|
|
* @author Divine Niiquaye Ibok <[email protected]> |
|
11
|
|
|
* @copyright 2019 Biurad Group (https://biurad.com/) |
|
12
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause License |
|
13
|
|
|
* |
|
14
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
15
|
|
|
* file that was distributed with this source code. |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
namespace Flight\Routing\Tests\Fixtures; |
|
19
|
|
|
|
|
20
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
21
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Class SampleController. |
|
25
|
|
|
*/ |
|
26
|
|
|
class SampleController |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* @return string |
|
30
|
|
|
*/ |
|
31
|
|
|
public function homePageString(): string |
|
32
|
|
|
{ |
|
33
|
|
|
return 'Welcome to Flight Router HomePage'; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @param ServerRequestInterface $request |
|
38
|
|
|
* |
|
39
|
|
|
* @return string |
|
40
|
|
|
*/ |
|
41
|
|
|
public function homePageRequestString(ServerRequestInterface $request): string |
|
42
|
|
|
{ |
|
43
|
|
|
return 'Hello, I\'m on a ' . $request->getMethod() . ' method'; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param ResponseInterface $response |
|
48
|
|
|
* |
|
49
|
|
|
* @return ResponseInterface |
|
50
|
|
|
*/ |
|
51
|
|
|
public function homePageResponse(ResponseInterface $response): ResponseInterface |
|
52
|
|
|
{ |
|
53
|
|
|
$response->getBody()->write('Welcome to Flight Router HomePage'); |
|
54
|
|
|
|
|
55
|
|
|
return $response; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param ServerRequestInterface $request |
|
60
|
|
|
* @param ResponseInterface $response |
|
61
|
|
|
* |
|
62
|
|
|
* @return ResponseInterface |
|
63
|
|
|
*/ |
|
64
|
|
|
public function homePageRequestResponse( |
|
65
|
|
|
ServerRequestInterface $request, |
|
66
|
|
|
ResponseInterface $response |
|
67
|
|
|
): ResponseInterface { |
|
68
|
|
|
$response->getBody()->write('Hello, I\'m on a ' . $request->getMethod() . ' method'); |
|
69
|
|
|
|
|
70
|
|
|
return $response; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function homePageRequestArray($arrayResponse = null) |
|
74
|
|
|
{ |
|
75
|
|
|
return null === $arrayResponse ? ['Hello Array', 'Cool Man'] : $arrayResponse; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|