Completed
Push — feature/fixing_cost ( ef981e )
by Laurent
01:53
created

Request::getPostParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace FlightLog\Http\Web\Requests;
5
6
7
final class Request
8
{
9
10
    /**
11
     * @param string $name
12
     * @param mixed $defaultValue
13
     *
14
     * @return mixed
15
     */
16
    public function getParam($name, $defaultValue = null){
17
        if($_POST[$name]){
18
            return $_POST[$name];
19
        }
20
21
        if($_GET[$name]){
22
            return $_GET[$name];
23
        }
24
25
        return $defaultValue;
26
    }
27
28
    /**
29
     * @return bool
30
     */
31
    public function isPost(){
32
        return strtoupper($_SERVER['REQUEST_METHOD']) === 'POST';
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function getPostParameters(){
39
        return $_POST;
40
    }
41
}