Add VariableManager, RpcClient classes, and cache enhancements
This commit is contained in:
parent
38092a639e
commit
e55f4d57f9
27 changed files with 606 additions and 56 deletions
|
@ -4,6 +4,7 @@ namespace Socialbox\Classes;
|
|||
|
||||
use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use Socialbox\Enums\StandardHeaders;
|
||||
|
||||
class Utilities
|
||||
{
|
||||
|
@ -34,6 +35,18 @@ class Utilities
|
|||
return $decoded;
|
||||
}
|
||||
|
||||
public static function jsonEncode(mixed $data): string
|
||||
{
|
||||
try
|
||||
{
|
||||
return json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
|
||||
}
|
||||
catch(\JsonException $e)
|
||||
{
|
||||
throw new \RuntimeException("Failed to encode json input", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the given data in Base64.
|
||||
*
|
||||
|
@ -117,4 +130,9 @@ class Utilities
|
|||
$e->getTraceAsString()
|
||||
);
|
||||
}
|
||||
|
||||
public static function generateHeader(StandardHeaders $header, string $value): string
|
||||
{
|
||||
return $header->value . ': ' . $value;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue