PluginProbe
User Access Manager / 2.2.2
User Access Manager v2.2.2
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
user-access-manager / src / Wrapper / Php.php

Php.php in User Access Manager 2.2.2, at src/Wrapper/Php.php

195 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Php.php
4 *
5 * The Php class file.
6 *
7 * PHP versions 5
8 *
9 * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 * @copyright 2008-2017 Alexander Schneider
11 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 * @version SVN: $id$
13 * @link http://wordpress.org/extend/plugins/user-access-manager/
14 */
15
16 declare(strict_types=1);
17
18 namespace UserAccessManager\Wrapper;
19
20 use Exception;
21
22 /**
23 * Class Php
24 *
25 * @package UserAccessManager\Wrapper
26 */
27 class Php
28 {
29 /**
30 * @param string $functionName
31 * @return bool
32 * @see function_exists()
33 */
34 public function functionExists(string $functionName): bool
35 {
36 return function_exists($functionName);
37 }
38
39 /**
40 * @param int $startIndex
41 * @param int $numberOfElements
42 * @param mixed $value
43 * @return array
44 * @see array_fill()
45 */
46 public function arrayFill(int $startIndex, int $numberOfElements, $value): array
47 {
48 return array_fill($startIndex, $numberOfElements, $value);
49 }
50
51 /**
52 * @param int $length
53 * @param null|bool $strong
54 * @return false|string
55 * @see openssl_random_pseudo_bytes()
56 */
57 public function opensslRandomPseudoBytes(int $length, ?bool &$strong = false)
58 {
59 return openssl_random_pseudo_bytes($length, $strong);
60 }
61
62 /**
63 * @param string $filename
64 * @param null $context
65 * @return bool
66 * @see unlink()
67 */
68 public function unlink(string $filename, $context = null): bool
69 {
70 return ($context !== null) ? unlink($filename, $context) : unlink($filename);
71 }
72
73 /**
74 * @param string $variableName
75 * @return int|string
76 * @see ini_get()
77 */
78 public function iniGet(string $variableName)
79 {
80 return ini_get($variableName);
81 }
82
83 /**
84 * @param int $seconds
85 * @return bool
86 * @see set_time_limit()
87 */
88 public function setTimeLimit(int $seconds): bool
89 {
90 return @set_time_limit($seconds);
91 }
92
93 /**
94 * @param resource $handle
95 * @param int $length
96 * @return bool|string
97 * @see fread()
98 */
99 public function fread($handle, int $length)
100 {
101 return fread($handle, $length);
102 }
103
104 /**
105 * @param mixed $controller
106 * @param string $file
107 * @throws Exception
108 */
109 public function includeFile($controller, string $file)
110 {
111 if ($controller === null) {
112 throw new Exception('Controller is required');
113 }
114
115 /** @noinspection PhpIncludeInspection */
116 include $file;
117 }
118
119 /**
120 * @see exit()
121 */
122 public function callExit()
123 {
124 exit;
125 }
126
127 /**
128 * @param string $filename
129 * @param mixed $data
130 * @param int $flags
131 * @param null $context
132 * @return bool|int
133 * @see file_put_contents()
134 */
135 public function filePutContents(string $filename, $data, $flags = 0, $context = null)
136 {
137 return file_put_contents($filename, $data, $flags, $context);
138 }
139
140 /**
141 * @param mixed $value
142 * @return string
143 * @see igbinary_serialize()
144 */
145 public function igbinarySerialize($value): string
146 {
147 /** @noinspection PhpUndefinedFunctionInspection */
148 return igbinary_serialize($value);
149 }
150
151 /**
152 * @param string $key
153 * @return mixed
154 * @see igbinary_unserialize()
155 */
156 public function igbinaryUnserialize(string $key)
157 {
158 /** @noinspection PhpUndefinedFunctionInspection */
159 return igbinary_unserialize($key);
160 }
161
162 /**
163 * @param string $pathname
164 * @param int $mode
165 * @param bool $recursive
166 * @param null $context
167 * @return bool
168 * @see mkdir()
169 */
170 public function mkdir(string $pathname, $mode = 0777, $recursive = false, $context = null): bool
171 {
172 return ($context !== null) ?
173 mkdir($pathname, $mode, $recursive, $context) : mkdir($pathname, $mode, $recursive);
174 }
175
176 /**
177 * @return int
178 * @see connection_status()
179 */
180 public function connectionStatus(): int
181 {
182 return connection_status();
183 }
184
185 /**
186 * @param resource $handle
187 * @return bool
188 * @see fclose()
189 */
190 public function fClose($handle): bool
191 {
192 return fclose($handle);
193 }
194 }
195