Php.php
4.15 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
* Php.php
*
* The Php class file.
*
* PHP versions 5
*
* @author Alexander Schneider <alexanderschneider85@gmail.com>
* @copyright 2008-2017 Alexander Schneider
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
* @version SVN: $id$
* @link http://wordpress.org/extend/plugins/user-access-manager/
*/
declare(strict_types=1);
namespace UserAccessManager\Wrapper;
use Exception;
/**
* Class Php
*
* @package UserAccessManager\Wrapper
*/
class Php
{
/**
* @param string $functionName
* @return bool
* @see function_exists()
*/
public function functionExists(string $functionName): bool
{
return function_exists($functionName);
}
/**
* @param int $startIndex
* @param int $numberOfElements
* @param mixed $value
* @return array
* @see array_fill()
*/
public function arrayFill(int $startIndex, int $numberOfElements, $value): array
{
return array_fill($startIndex, $numberOfElements, $value);
}
/**
* @param int $length
* @param null|bool $strong
* @return false|string
* @see openssl_random_pseudo_bytes()
*/
public function opensslRandomPseudoBytes(int $length, ?bool &$strong = false)
{
return openssl_random_pseudo_bytes($length, $strong);
}
/**
* @param string $filename
* @param null $context
* @return bool
* @see unlink()
*/
public function unlink(string $filename, $context = null): bool
{
return ($context !== null) ? unlink($filename, $context) : unlink($filename);
}
/**
* @param string $variableName
* @return int|string
* @see ini_get()
*/
public function iniGet(string $variableName)
{
return ini_get($variableName);
}
/**
* @param int $seconds
* @return bool
* @see set_time_limit()
*/
public function setTimeLimit(int $seconds): bool
{
return @set_time_limit($seconds);
}
/**
* @param resource $handle
* @param int $length
* @return bool|string
* @see fread()
*/
public function fread($handle, int $length)
{
return fread($handle, $length);
}
/**
* @param mixed $controller
* @param string $file
* @throws Exception
*/
public function includeFile($controller, string $file)
{
if ($controller === null) {
throw new Exception('Controller is required');
}
/** @noinspection PhpIncludeInspection */
include $file;
}
/**
* @see exit()
*/
public function callExit()
{
exit;
}
/**
* @param string $filename
* @param mixed $data
* @param int $flags
* @param null $context
* @return bool|int
* @see file_put_contents()
*/
public function filePutContents(string $filename, $data, $flags = 0, $context = null)
{
return file_put_contents($filename, $data, $flags, $context);
}
/**
* @param mixed $value
* @return string
* @see igbinary_serialize()
*/
public function igbinarySerialize($value): string
{
return igbinary_serialize($value);
}
/**
* @param string $key
* @return mixed
* @see igbinary_unserialize()
*/
public function igbinaryUnserialize(string $key)
{
return igbinary_unserialize($key);
}
/**
* @param string $pathname
* @param int $mode
* @param bool $recursive
* @param null $context
* @return bool
* @see mkdir()
*/
public function mkdir(string $pathname, $mode = 0777, $recursive = false, $context = null): bool
{
return ($context !== null) ?
mkdir($pathname, $mode, $recursive, $context) : mkdir($pathname, $mode, $recursive);
}
/**
* @return int
* @see connection_status()
*/
public function connectionStatus(): int
{
return connection_status();
}
/**
* @param resource $handle
* @return bool
* @see fclose()
*/
public function fClose($handle): bool
{
return fclose($handle);
}
}