Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
AbstractStorage | |
100.00% |
10 / 10 |
|
100.00% |
5 / 5 |
8 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
setFormat | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
3 | |||
isPhp | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isJson | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFormat | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
save | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
get | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
has | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
delete | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
clear | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
encodeValue | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
decodeValue | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | /** |
3 | * Pop PHP Framework (http://www.popphp.org/) |
4 | * |
5 | * @link https://github.com/popphp/popphp-framework |
6 | * @author Nick Sagona, III <dev@nolainteractive.com> |
7 | * @copyright Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
8 | * @license http://www.popphp.org/license New BSD License |
9 | */ |
10 | |
11 | /** |
12 | * @namespace |
13 | */ |
14 | namespace Pop\Debug\Storage; |
15 | |
16 | /** |
17 | * Debug storage abstract class |
18 | * |
19 | * @category Pop |
20 | * @package Pop\Debug |
21 | * @author Nick Sagona, III <dev@nolainteractive.com> |
22 | * @copyright Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com) |
23 | * @license http://www.popphp.org/license New BSD License |
24 | * @version 1.3.0 |
25 | */ |
26 | abstract class AbstractStorage implements StorageInterface |
27 | { |
28 | |
29 | /** |
30 | * Format constants |
31 | */ |
32 | const JSON = 'JSON'; |
33 | const PHP = 'PHP'; |
34 | |
35 | /** |
36 | * Storage format (json, php or text) |
37 | * @var string |
38 | */ |
39 | protected $format = null; |
40 | |
41 | /** |
42 | * Constructor |
43 | * |
44 | * Instantiate the storage object |
45 | * |
46 | * @param string $format |
47 | */ |
48 | public function __construct($format = null) |
49 | { |
50 | if (null !== $format) { |
51 | $this->setFormat($format); |
52 | } |
53 | } |
54 | |
55 | /** |
56 | * Set the storage format |
57 | * |
58 | * @param string $format |
59 | * @return AbstractStorage |
60 | */ |
61 | public function setFormat($format) |
62 | { |
63 | switch (strtoupper($format)) { |
64 | case self::JSON: |
65 | $this->format = self::JSON; |
66 | break; |
67 | case self::PHP: |
68 | $this->format = self::PHP; |
69 | } |
70 | |
71 | return $this; |
72 | } |
73 | |
74 | /** |
75 | * Determine if the format is PHP |
76 | * |
77 | * @return boolean |
78 | */ |
79 | public function isPhp() |
80 | { |
81 | return ($this->format == self::PHP); |
82 | } |
83 | |
84 | /** |
85 | * Determine if the format is JSON |
86 | * |
87 | * @return boolean |
88 | */ |
89 | public function isJson() |
90 | { |
91 | return ($this->format == self::JSON); |
92 | } |
93 | |
94 | /** |
95 | * Get the storage format |
96 | * |
97 | * @return string |
98 | */ |
99 | public function getFormat() |
100 | { |
101 | return $this->format; |
102 | } |
103 | |
104 | /** |
105 | * Save debug data |
106 | * |
107 | * @param string $id |
108 | * @param mixed $value |
109 | * @return void |
110 | */ |
111 | abstract public function save($id, $value); |
112 | |
113 | /** |
114 | * Get debug data |
115 | * |
116 | * @param string $id |
117 | * @return mixed |
118 | */ |
119 | abstract public function get($id); |
120 | |
121 | /** |
122 | * Determine if debug data exists |
123 | * |
124 | * @param string $id |
125 | * @return mixed |
126 | */ |
127 | abstract public function has($id); |
128 | |
129 | /** |
130 | * Delete debug data |
131 | * |
132 | * @param string $id |
133 | * @return void |
134 | */ |
135 | abstract public function delete($id); |
136 | |
137 | /** |
138 | * Clear all debug data |
139 | * |
140 | * @return void |
141 | */ |
142 | abstract public function clear(); |
143 | |
144 | /** |
145 | * Encode the value based on the format |
146 | * |
147 | * @param mixed $value |
148 | * @return string |
149 | */ |
150 | abstract public function encodeValue($value); |
151 | |
152 | /** |
153 | * Decode the value based on the format |
154 | * |
155 | * @param mixed $value |
156 | * @return mixed |
157 | */ |
158 | abstract public function decodeValue($value); |
159 | |
160 | } |