PluginProbe
User Access Manager / 2.2.21
User Access Manager v2.2.21
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.21, at src/Wrapper/Php.php

193 lines 4.1 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 return igbinary_serialize($value);
148 }
149
150 /**
151 * @param string $key
152 * @return mixed
153 * @see igbinary_unserialize()
154 */
155 public function igbinaryUnserialize(string $key)
156 {
157 return igbinary_unserialize($key);
158 }
159
160 /**
161 * @param string $pathname
162 * @param int $mode
163 * @param bool $recursive
164 * @param null $context
165 * @return bool
166 * @see mkdir()
167 */
168 public function mkdir(string $pathname, $mode = 0777, $recursive = false, $context = null): bool
169 {
170 return ($context !== null) ?
171 mkdir($pathname, $mode, $recursive, $context) : mkdir($pathname, $mode, $recursive);
172 }
173
174 /**
175 * @return int
176 * @see connection_status()
177 */
178 public function connectionStatus(): int
179 {
180 return connection_status();
181 }
182
183 /**
184 * @param resource $handle
185 * @return bool
186 * @see fclose()
187 */
188 public function fClose($handle): bool
189 {
190 return fclose($handle);
191 }
192 }
193