Passed
Pull Request — master (#244)
by Alex
22:10
created

IlluminateOperationContext::incomingRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlgoWeb\PODataLaravel\OperationContext\Web\Illuminate;
6
7
use Illuminate\Http\Request;
8
use POData\OperationContext\IOperationContext;
9
use POData\OperationContext\Web\OutgoingResponse;
10
11
/**
12
 * Class IlluminateOperationContext.
13
 * @package POData\OperationContext\Web\Illuminate
14
 */
15
class IlluminateOperationContext implements IOperationContext
16
{
17
    /**
18
     * Object of IncomingRequest which is needed to get all the HTTP headers info.
19
     *
20
     * @var IncomingIlluminateRequest
21
     */
22
    private $incomingRequest;
23
24
    /**
25
     * Object of OutgoingResponse which is needed to get all the HTTP headers info.
26
     *
27
     * @var OutgoingResponse
28
     */
29
    private $outgoingResponse;
30
31
    /**
32
     * Initializes a new instance of the IlluminateOperationContext class.
33
     * This function will perform the following tasks:
34
     *  (1) Retrieve the current HTTP method,headers and stream.
35
     *  (2) Populate $_incomingRequest using these.
36
     *
37
     * @param Request $request
38
     */
39
    public function __construct(Request $request)
40
    {
41
        $this->incomingRequest  = new IncomingIlluminateRequest($request);
42
        $this->outgoingResponse = new OutgoingResponse();
43
    }
44
45
    /**
46
     * Gets the Web request context for the request being sent.
47
     *
48
     * @return OutgoingResponse
49
     */
50
    public function outgoingResponse(): OutgoingResponse
51
    {
52
        return $this->outgoingResponse;
53
    }
54
55
    /**
56
     * Gets the Web request context for the request being received.
57
     *
58
     * @return IncomingIlluminateRequest
59
     */
60
    public function incomingRequest(): IncomingIlluminateRequest
61
    {
62
        return $this->incomingRequest;
63
    }
64
}
65