Request   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 124
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 27
c 1
b 0
f 0
dl 0
loc 124
rs 10
wmc 13

12 Methods

Rating   Name   Duplication   Size   Complexity  
A setQuery() 0 3 1
A getMethod() 0 3 1
A getQuery() 0 3 1
A getContentType() 0 3 1
A setBody() 0 4 1
A toArray() 0 8 1
A setContentType() 0 3 1
A setMethod() 0 3 1
A setPath() 0 3 1
A getPath() 0 3 1
A __construct() 0 6 2
A getBody() 0 3 1
1
<?php
2
3
4
namespace Manticoresearch;
5
6
/**
7
 * Class Request
8
 * @package Manticoresearch
9
 */
10
class Request
11
{
12
    /**
13
     * @var string
14
     */
15
    protected $path;
16
    /**
17
     * @var string
18
     */
19
    protected $method;
20
    /**
21
     * @var array|string
22
     */
23
    protected $body;
24
    /**
25
     * @var string
26
     */
27
    protected $query;
28
    /**
29
     * @var string
30
     */
31
    protected $content_type;
32
33
    public function __construct($params = [])
34
    {
35
        if (count($params)>0) {
36
            $this->setBody($params['body'] ?? []);
37
            $this->setQuery($params['query'] ?? []);
38
            $this->setContentType($params['content_type'] ?? 'application/json');
39
        }
40
    }
41
42
    /**
43
     * @return mixed
44
     */
45
    public function getPath()
46
    {
47
        return $this->path;
48
    }
49
50
    /**
51
     * @param mixed $path
52
     */
53
    public function setPath($path)
54
    {
55
        $this->path = $path;
56
    }
57
58
    /**
59
     * @return mixed
60
     */
61
    public function getBody()
62
    {
63
        return $this->body;
64
    }
65
66
    /**
67
     * @param mixed $body
68
     */
69
70
    public function setBody($body = null)
71
    {
72
        $this->body = $body;
73
        return $this;
74
    }
75
76
    /**
77
     * @return mixed
78
     */
79
    public function getMethod()
80
    {
81
        return $this->method;
82
    }
83
84
    /**
85
     * @param mixed $method
86
     */
87
    public function setMethod($method)
88
    {
89
        $this->method = $method;
90
    }
91
92
    /**
93
     * @return mixed
94
     */
95
    public function getContentType()
96
    {
97
        return $this->content_type;
98
    }
99
100
    /**
101
     * @param mixed $content_type
102
     */
103
    public function setContentType($content_type)
104
    {
105
        $this->content_type = $content_type;
106
    }
107
108
    /**
109
     * @return mixed
110
     */
111
    public function getQuery()
112
    {
113
        return $this->query;
114
    }
115
116
    /**
117
     * @param mixed $query
118
     */
119
    public function setQuery($query)
120
    {
121
        $this->query = $query;
122
    }
123
    /*
124
     * #return string
125
     */
126
    public function toArray()
127
    {
128
        return [
129
            'path' => $this->getPath(),
130
            'method' => $this->getMethod(),
131
            'content_type' => $this->getContentType(),
132
            'query' => $this->getQuery(),
133
            'body' => $this->getBody()
134
        ];
135
    }
136
}
137