Minor changes
This commit is contained in:
parent
05cc358eea
commit
e9d033044c
27 changed files with 949 additions and 94 deletions
27
src/RTEX/Classes/RedisHookInstance.php
Normal file
27
src/RTEX/Classes/RedisHookInstance.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php /** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace RTEX\Classes;
|
||||
|
||||
use RedisClient\RedisClient;
|
||||
|
||||
class RedisHookInstance
|
||||
{
|
||||
public function __construct(string $host, int $port, ?string $password=null)
|
||||
{
|
||||
if(extension_loaded('redis'))
|
||||
{
|
||||
$this->Redis = new \Redis();
|
||||
$this->Redis->connect($host, $port);
|
||||
if($password !== null)
|
||||
$this->Redis->auth($password);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->Redis = new RedisClient([
|
||||
'host' => $host,
|
||||
'port' => $port,
|
||||
'password' => $password
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -12,10 +12,11 @@
|
|||
* Determines the type of variable, throws an exception if the type is not supported
|
||||
*
|
||||
* @param $input
|
||||
* @param bool $return_unknown
|
||||
* @return string
|
||||
* @throws TypeException
|
||||
*/
|
||||
public static function getType($input): string
|
||||
public static function getType($input, bool $return_unknown=false): string
|
||||
{
|
||||
if ($input instanceof InstructionInterface)
|
||||
return VariableType::Instruction;
|
||||
|
@ -33,6 +34,8 @@
|
|||
return VariableType::Array;
|
||||
if (is_null($input))
|
||||
return VariableType::Null;
|
||||
if ($return_unknown)
|
||||
return VariableType::Unknown;
|
||||
|
||||
throw new TypeException(gettype($input));
|
||||
}
|
||||
|
@ -43,9 +46,8 @@
|
|||
*
|
||||
* @param $input
|
||||
* @return array|mixed
|
||||
* @noinspection PhpMissingReturnTypeInspection
|
||||
*/
|
||||
public static function toArray($input)
|
||||
public static function toArray($input): mixed
|
||||
{
|
||||
if($input instanceof InstructionInterface)
|
||||
return $input->toArray();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue