| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace UserAccessManager\Wrapper; |
| 6 |
|
| 7 |
use Exception; |
| 8 |
use JetBrains\PhpStorm\NoReturn; |
| 9 |
|
| 10 |
class Php |
| 11 |
{ |
| 12 |
/** |
| 13 |
* @see function_exists() |
| 14 |
*/ |
| 15 |
public function functionExists(string $functionName): bool |
| 16 |
{ |
| 17 |
return function_exists($functionName); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* @see array_fill() |
| 22 |
*/ |
| 23 |
public function arrayFill(int $startIndex, int $numberOfElements, mixed $value): array |
| 24 |
{ |
| 25 |
return array_fill($startIndex, $numberOfElements, $value); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* @see openssl_random_pseudo_bytes() |
| 30 |
*/ |
| 31 |
public function opensslRandomPseudoBytes(int $length, ?bool &$strong = false): bool|string |
| 32 |
{ |
| 33 |
return openssl_random_pseudo_bytes($length, $strong); |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* @param string $filename |
| 38 |
* @param null $context |
| 39 |
* @return bool |
| 40 |
* @see unlink() |
| 41 |
*/ |
| 42 |
public function unlink(string $filename, $context = null): bool |
| 43 |
{ |
| 44 |
return ($context !== null) ? unlink($filename, $context) : unlink($filename); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* @see ini_get() |
| 49 |
*/ |
| 50 |
public function iniGet(string $variableName): int|string|false |
| 51 |
{ |
| 52 |
return ini_get($variableName); |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* @see set_time_limit() |
| 57 |
*/ |
| 58 |
public function setTimeLimit(int $seconds): bool |
| 59 |
{ |
| 60 |
return @set_time_limit($seconds); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* @see fread() |
| 65 |
*/ |
| 66 |
public function fread($handle, int $length): false|string |
| 67 |
{ |
| 68 |
return fread($handle, $length); |
| 69 |
} |
| 70 |
|
| 71 |
/** |
| 72 |
* @throws Exception |
| 73 |
*/ |
| 74 |
public function includeFile($controller, string $file): void |
| 75 |
{ |
| 76 |
if ($controller === null) { |
| 77 |
throw new Exception('Controller is required'); |
| 78 |
} |
| 79 |
|
| 80 |
include $file; |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* @see exit() |
| 85 |
*/ |
| 86 |
#[NoReturn] |
| 87 |
public function callExit(): void |
| 88 |
{ |
| 89 |
exit; |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* @see file_put_contents() |
| 94 |
*/ |
| 95 |
public function filePutContents(string $filename, mixed $data, int $flags = 0, $context = null): false|int |
| 96 |
{ |
| 97 |
return file_put_contents($filename, $data, $flags, $context); |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* @see igbinary_serialize() |
| 102 |
*/ |
| 103 |
public function igbinarySerialize(mixed $value): ?string |
| 104 |
{ |
| 105 |
return igbinary_serialize($value); |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* @see igbinary_unserialize() |
| 110 |
*/ |
| 111 |
public function igbinaryUnserialize(string $key): mixed |
| 112 |
{ |
| 113 |
return igbinary_unserialize($key); |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* @see mkdir() |
| 118 |
*/ |
| 119 |
public function mkdir(string $pathname, int $mode = 0777, bool $recursive = false, $context = null): bool |
| 120 |
{ |
| 121 |
return ($context !== null) |
| 122 |
? mkdir($pathname, $mode, $recursive, $context) |
| 123 |
: mkdir($pathname, $mode, $recursive); |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* @see connection_status() |
| 128 |
*/ |
| 129 |
public function connectionStatus(): int |
| 130 |
{ |
| 131 |
return connection_status(); |
| 132 |
} |
| 133 |
|
| 134 |
/** |
| 135 |
* @see fclose() |
| 136 |
*/ |
| 137 |
public function fClose($handle): bool |
| 138 |
{ |
| 139 |
return fclose($handle); |
| 140 |
} |
| 141 |
} |
| 142 |
|