Request.php
1.66 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
namespace Wpo\Core;
// Prevent public access to this script
defined( 'ABSPATH' ) or die();
if ( !class_exists( '\Wpo\Core\Request' ) ) {
class Request {
private $id;
private $storage = array();
public function __construct( $id ) {
$this->id = $id;
}
public function current_request_id() {
return $this->id;
}
public function set_item( $key, $value ) {
if ( !is_string( $key ) ) {
return false;
}
if ( empty( $key ) ) {
return false;
}
$this->storage[ $key ] = $value;
return true;
}
public function get_item( $key ) {
if ( !is_string( $key ) || empty( $key ) ) {
return false;
}
if ( array_key_exists( $key, $this->storage ) ) {
return $this->storage[ $key ];
}
return false;
}
public function remove_item( $key ) {
if ( !is_string( $key ) || empty( $key ) ) {
return false;
}
if ( array_key_exists( $key, $this->storage ) ) {
unset( $this->storage[ $key ] );
return true;
}
return false;
}
public function clear() {
$this->storage = array();
}
}
}