1
<?php
2
/**
3
 * This file is part of the Shieldon package.
4
 *
5
 * (c) Terry L. <contact@terryl.in>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * php version 7.1.0
11
 *
12
 * @category  Web-security
13
 * @package   Shieldon
14
 * @author    Terry Lin <contact@terryl.in>
15
 * @copyright 2019 terrylinooo
16
 * @license   https://github.com/terrylinooo/shieldon/blob/2.x/LICENSE MIT
17
 * @link      https://github.com/terrylinooo/shieldon
18
 * @see       https://shieldon.io
19
 */
20

21
declare(strict_types=1);
22

23
namespace Shieldon\Firewall;
24

25
use Shieldon\Firewall\Session;
26
use Shieldon\Psr17\ResponseFactory;
27
use Shieldon\Psr17\ServerRequestFactory;
28
use Shieldon\Psr17\StreamFactory;
29
use Shieldon\Psr7\Response;
30
use Shieldon\Psr7\ServerRequest;
31
use Shieldon\Psr7\Stream;
32

33
/**
34
 * An object-oriented layer for the HTTP specification.
35
 */
36
class HttpFactory
37
{
38
    /**
39
     * Create a server-side request.
40
     *
41
     * @return ServerRequest
42
     */
43 3
    public static function createRequest(): ServerRequest
44
    {
45 3
        return ServerRequestFactory::fromGlobal();
46
    }
47

48
    /**
49
     * Create a server-side response
50
     *
51
     * @return Response
52
     */
53 3
    public static function createResponse(): Response
54
    {
55 3
        return ResponseFactory::fromNew();
56
    }
57

58
    /**
59
     * Create a server-side response
60
     *
61
     * @return Stream
62
     */
63 3
    public static function createStream(): Stream
64
    {
65 3
        return StreamFactory::fromNew();
66
    }
67

68
    /**
69
     * Create a session by using Shieldon's Session driver.
70
     *
71
     * @param string $id Session ID
72
     *
73
     * @return Session
74
     */
75 3
    public static function createSession($id = ''): Session
76
    {
77 3
        return new Session($id);
78
    }
79
}

Read our documentation on viewing source code .

Loading