Skip to content

Wiki Data

Danijel Galić edited this page Jan 23, 2024 · 1 revision
final class \FireHub\Core\Support\LowLevel\Data()

Important

This class is marked as final.

### Data low-level proxy class

Class contains variable handling methods.

This class was created by Danijel Galić <danijel.galic@outlook.com>
Copyright: 2024 FireHub Web Application Framework
License: <https://opensource.org/licenses/OSL-3.0> OSL Open Source License version 3
Version: GIT: $Id$ Blob checksum.

Fully Qualified Class Name:  \FireHub\Core\Support\LowLevel\Data
Source code:  view source code
Blame:  view blame
History:  view history

Methods

Type Name Title
public static getType ### Gets data type
public static setType ### Sets data type
public static serializeValue ### Generates storable representation of data
public static unserializeValue ### Creates a PHP value from a stored representation
public static Data::getType(mixed $value):\FireHub\Core\Support\Enums\Data\Type

### Gets data type

Source code:  view source code
Blame:  view blame

Parameters

  • mixed $value - The variable being type checked.

Throws

  • \Error - If a type of value is unknown.

Returns

public static Data::setType(mixed $value, \FireHub\Core\Support\Enums\Data\Type $type):mixed

### Sets data type

Source code:  view source code
Blame:  view blame

Parameters

Throws

  • \Error - If a type cannot be set to resource or failed to set a type for value.

Returns

  • mixed - Converted value.
public static Data::serializeValue(string|int|float|bool|array|object|null $value):string

Warning

When serialize() serializes objects, the leading backslash is not included in the class name of namespaced classes for maximum compatibility.> [!NOTE] This is a binary string that may include null bytes and needs to be stored and handled as such. For example, serialize() output should generally be stored in a BLOB field in a database, rather than a CHAR or TEXT field.

### Generates storable representation of data

Generates a storable representation of a value. This is useful for storing or passing PHP values around without losing their type and structure. To make the serialized string into a PHP value again, use unserialize().

Source code:  view source code
Blame:  view blame

Parameters

  • string or int or float or bool or array or object or null $value - scalar|array<array-key, mixed>|object|null The value to be serialized.

Throws

  • \Error - If try to serialize anonymous class, function or resource.

Returns

  • string - String containing a byte-stream representation of value that can be stored anywhere.
public static Data::unserializeValue(string $data, bool|array $allowed_classes = false, int $max_depth = 4096):mixed

### Creates a PHP value from a stored representation

Source code:  view source code
Blame:  view blame

Parameters

  • string $data - non-empty-string The serialized string.
  • bool or array $allowed_classes = false - [optional] bool|array Either an array of class names which should be accepted, false to accept no classes, or true to accept all classes.
  • int $max_depth = 4096 - [optional] The maximum depth of structures permitted during unserialization, and is intended to prevent stack overflows.

Throws

  • \Error - $data is already false already or $data is NULL, or could not unserialize data.

Returns

  • mixed - The converted value is returned.
Clone this wiki locally