-
Notifications
You must be signed in to change notification settings - Fork 40
/
SimpleRequest.php
54 lines (49 loc) · 1.1 KB
/
SimpleRequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Dilab\Network;
use Dilab\Network\Request;
class SimpleRequest implements Request
{
/**
* @param $type get/post
* @return boolean
*/
public function is($type)
{
switch (strtolower($type)) {
case 'post':
return isset($_POST)&&!empty($_POST);
break;
case 'get':
return isset($_GET)&&!empty($_GET);
break;
}
return false;
}
/**
* @param $requestType GET/POST
* @return mixed
*/
public function data($requestType)
{
switch (strtolower($requestType)) {
case 'post':
return isset($_POST)?$_POST:array();
break;
case 'get':
return isset($_GET)?$_GET:array();
break;
}
return array();
}
/**
* @return FILES data
*/
public function file()
{
if (!isset($_FILES) || empty($_FILES)) {
return array();
}
$files = array_values($_FILES);
return array_shift($files);
}
}