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

Request   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getParam() 0 11 3
A isPost() 0 3 1
A getPostParameters() 0 3 1
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
}