Skip to content

Commit 2fad64c

Browse files
Merge pull request #62 from Spudley/master
Refactoring of UploadHandler, per issue #28
2 parents c1f4827 + 0982080 commit 2fad64c

File tree

4 files changed

+371
-310
lines changed

4 files changed

+371
-310
lines changed

app/Libraries/RequestHandler.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace App\Libraries;
4+
5+
//@todo: When happy to support PHP 7 and above only, we can swap the use of isset()?: for ??
6+
class RequestHandler
7+
{
8+
public function get_upload_data($id)
9+
{
10+
return isset($_FILES[$id]) ? $_FILES[$id] : null;
11+
}
12+
13+
public function get_post_param($id)
14+
{
15+
return isset($_POST[$id]) ? $_POST[$id] : null;
16+
}
17+
18+
public function get_query_param($id)
19+
{
20+
return isset($_GET[$id]) ? $_GET[$id] : null;
21+
}
22+
23+
public function get_server_var($id)
24+
{
25+
return isset($_SERVER[$id]) ? $_SERVER[$id] : null;
26+
}
27+
}

app/Libraries/ResponseHandler.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Libraries;
4+
5+
class ResponseHandler
6+
{
7+
protected $response = [];
8+
9+
public function set_response(array $content)
10+
{
11+
$this->response = $content;
12+
}
13+
public function get_response()
14+
{
15+
return $this->response;
16+
}
17+
18+
public function body($str)
19+
{
20+
echo $str;
21+
}
22+
23+
public function header($str)
24+
{
25+
header($str);
26+
}
27+
28+
}

0 commit comments

Comments
 (0)