| 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 |
namespace UserAccessManager\Wrapper; |
| 16 |
|
| 17 |
/** |
| 18 |
* Class Php |
| 19 |
* |
| 20 |
* @package UserAccessManager\Wrapper |
| 21 |
*/ |
| 22 |
class Php |
| 23 |
{ |
| 24 |
/** |
| 25 |
* @see function_exists() |
| 26 |
* |
| 27 |
* @param string $functionName |
| 28 |
* |
| 29 |
* @return bool |
| 30 |
*/ |
| 31 |
public function functionExists($functionName) |
| 32 |
{ |
| 33 |
return function_exists($functionName); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* @see array_fill() |
| 38 |
* |
| 39 |
* @param int $startIndex |
| 40 |
* @param int $numberOfElements |
| 41 |
* @param mixed $value |
| 42 |
* |
| 43 |
* @return array |
| 44 |
*/ |
| 45 |
public function arrayFill($startIndex, $numberOfElements, $value) |
| 46 |
{ |
| 47 |
return array_fill($startIndex, $numberOfElements, $value); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* @see openssl_random_pseudo_bytes() |
| 52 |
* |
| 53 |
* @param int $length |
| 54 |
* @param bool $strong |
| 55 |
* |
| 56 |
* @return string |
| 57 |
*/ |
| 58 |
public function opensslRandomPseudoBytes($length, &$strong) |
| 59 |
{ |
| 60 |
return openssl_random_pseudo_bytes($length, $strong); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* @see unlink() |
| 65 |
* |
| 66 |
* @param string $filename |
| 67 |
* @param resource $context |
| 68 |
* |
| 69 |
* @return bool |
| 70 |
*/ |
| 71 |
public function unlink($filename, $context = null) |
| 72 |
{ |
| 73 |
return ($context !== null) ? unlink($filename, $context) : unlink($filename); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* @see ini_get() |
| 78 |
* |
| 79 |
* @param string $variableName |
| 80 |
* |
| 81 |
* @return string |
| 82 |
*/ |
| 83 |
public function iniGet($variableName) |
| 84 |
{ |
| 85 |
return ini_get($variableName); |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* @see set_time_limit() |
| 90 |
* |
| 91 |
* @param int $seconds |
| 92 |
* |
| 93 |
* @return bool |
| 94 |
*/ |
| 95 |
public function setTimeLimit($seconds) |
| 96 |
{ |
| 97 |
return set_time_limit($seconds); |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* @see fread() |
| 102 |
* |
| 103 |
* @param resource $handle |
| 104 |
* @param int $length |
| 105 |
* |
| 106 |
* @return bool|string |
| 107 |
*/ |
| 108 |
public function fread($handle, $length) |
| 109 |
{ |
| 110 |
return fread($handle, $length); |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* @param mixed $controller |
| 115 |
* @param string $file |
| 116 |
* |
| 117 |
* @throws \Exception |
| 118 |
*/ |
| 119 |
public function includeFile(&$controller, $file) |
| 120 |
{ |
| 121 |
if ($controller === null) { |
| 122 |
throw new \Exception('Controller is required'); |
| 123 |
} |
| 124 |
|
| 125 |
/** @noinspection PhpIncludeInspection */ |
| 126 |
include $file; |
| 127 |
} |
| 128 |
|
| 129 |
/** |
| 130 |
* @see exit() |
| 131 |
*/ |
| 132 |
public function callExit() |
| 133 |
{ |
| 134 |
exit; |
| 135 |
} |
| 136 |
|
| 137 |
/** |
| 138 |
* @see file_put_contents() |
| 139 |
* |
| 140 |
* @param string $filename |
| 141 |
* @param mixed $data |
| 142 |
* @param int $flags |
| 143 |
* @param null $context |
| 144 |
* |
| 145 |
* @return bool|int |
| 146 |
*/ |
| 147 |
public function filePutContents($filename, $data, $flags = 0, $context = null) |
| 148 |
{ |
| 149 |
return file_put_contents($filename, $data, $flags, $context); |
| 150 |
} |
| 151 |
|
| 152 |
/** |
| 153 |
* @see igbinary_serialize() |
| 154 |
* |
| 155 |
* @param mixed $value |
| 156 |
* |
| 157 |
* @return string |
| 158 |
*/ |
| 159 |
public function igbinarySerialize($value) |
| 160 |
{ |
| 161 |
/** @noinspection PhpUndefinedFunctionInspection */ |
| 162 |
return igbinary_serialize($value); |
| 163 |
} |
| 164 |
|
| 165 |
/** |
| 166 |
* @see igbinary_unserialize() |
| 167 |
* |
| 168 |
* @param string $key |
| 169 |
* |
| 170 |
* @return mixed |
| 171 |
*/ |
| 172 |
public function igbinaryUnserialize($key) |
| 173 |
{ |
| 174 |
/** @noinspection PhpUndefinedFunctionInspection */ |
| 175 |
return igbinary_unserialize($key); |
| 176 |
} |
| 177 |
|
| 178 |
/** |
| 179 |
* @see mkdir() |
| 180 |
* |
| 181 |
* @param string $pathname |
| 182 |
* @param int $mode |
| 183 |
* @param bool $recursive |
| 184 |
* @param resource $context |
| 185 |
* |
| 186 |
* @return bool |
| 187 |
*/ |
| 188 |
public function mkdir($pathname, $mode = 0777, $recursive = false, $context = null) |
| 189 |
{ |
| 190 |
return ($context !== null) ? |
| 191 |
mkdir($pathname, $mode, $recursive, $context) : mkdir($pathname, $mode, $recursive); |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* @see connection_status() |
| 196 |
* |
| 197 |
* @return int |
| 198 |
*/ |
| 199 |
public function connectionStatus() |
| 200 |
{ |
| 201 |
return connection_status(); |
| 202 |
} |
| 203 |
|
| 204 |
/** |
| 205 |
* @see fclose() |
| 206 |
* |
| 207 |
* @param resource $handle |
| 208 |
* |
| 209 |
* @return bool |
| 210 |
*/ |
| 211 |
public function fClose($handle) |
| 212 |
{ |
| 213 |
return fclose($handle); |
| 214 |
} |
| 215 |
} |
| 216 |
|