Started work on Address
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
class mfRequest {
|
||||
protected static $instance;
|
||||
protected $request = [];
|
||||
|
||||
public function __construct(Array $request = []) {
|
||||
if(count($request)) {
|
||||
$this->request = $request;
|
||||
} else {
|
||||
// get request from POST/GET
|
||||
if(isset($_POST) && isset($_GET)) {
|
||||
$this->request = array_merge($_GET, $_POST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function singleton($request = false) {
|
||||
if(!isset(self::$instance)) {
|
||||
$c=__CLASS__;
|
||||
self::$instance=new $c($request);
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function set($name, $value) {
|
||||
if($name) {
|
||||
$this->request[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function get($name = null) {
|
||||
if($name) {
|
||||
if(array_key_exists($name, $this->request)) {
|
||||
//var_dump($this->request);exit;
|
||||
return $this->request[$name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function __get($name) {
|
||||
return $this->get($name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user