VRequest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A post() 0 3 1
A sr() 0 3 1
A payload() 0 3 1
A get() 0 3 1
A cookies() 0 3 1
1
<?php
2
/**
3
 * Request related vars
4
 * User: moyo
5
 * Date: 2018/5/29
6
 * Time: 11:06 PM
7
 */
8
9
namespace Carno\Web\Chips\Controller;
10
11
use Carno\HTTP\Standard\ServerRequest;
12
use Carno\Web\Controller\VGetter;
13
14
trait VRequest
15
{
16
    use VMixed;
17
18
    /**
19
     * @var VGetter
20
     */
21
    private $vgg = null;
22
23
    /**
24
     * @var VGetter
25
     */
26
    private $vgp = null;
27
28
    /**
29
     * @var VGetter
30
     */
31
    private $vgc = null;
32
33
    /**
34
     * @return ServerRequest
35
     */
36
    private function sr() : ServerRequest
37
    {
38
        return $this->server;
39
    }
40
41
    /**
42
     * @return VGetter
43
     */
44
    public function get() : VGetter
45
    {
46
        return $this->vgg ?? $this->vgg = new VGetter($this->sr()->getQueryParams());
47
    }
48
49
    /**
50
     * @return VGetter
51
     */
52
    public function post() : VGetter
53
    {
54
        return $this->vgp ?? $this->vgp = new VGetter($this->sr()->getParsedBody());
55
    }
56
57
    /**
58
     * @return VGetter
59
     */
60
    public function cookies() : VGetter
61
    {
62
        return $this->vgc ?? $this->vgc = new VGetter($this->sr()->getCookieParams());
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function payload() : string
69
    {
70
        return (string) $this->sr()->getBody();
71
    }
72
}
73