Skip to content

Helpers API

Complete API reference for helper classes.

get(string $key, mixed $default = null): mixed

Section titled “get(string $key, mixed $default = null): mixed”

Get environment variable.

$value = EnvHelper::get('APP_NAME', 'default');

Check if variable exists.

if (EnvHelper::has('API_KEY')) {
// ...
}

Set environment variable.

EnvHelper::set('APP_ENV', 'production');

add(string $a, string $b, int $scale = 2): string

Section titled “add(string $a, string $b, int $scale = 2): string”

Add two numbers.

$result = MathHelper::add('0.1', '0.2', 2); // '0.30'

subtract(string $a, string $b, int $scale = 2): string

Section titled “subtract(string $a, string $b, int $scale = 2): string”

Subtract two numbers.

$result = MathHelper::subtract('1.0', '0.3', 2); // '0.70'

multiply(string $a, string $b, int $scale = 2): string

Section titled “multiply(string $a, string $b, int $scale = 2): string”

Multiply two numbers.

$result = MathHelper::multiply('2.5', '3.0', 2); // '7.50'

divide(string $a, string $b, int $scale = 2): string

Section titled “divide(string $a, string $b, int $scale = 2): string”

Divide two numbers.

$result = MathHelper::divide('10.0', '3.0', 2); // '3.33'

Compare two numbers.

$cmp = MathHelper::compare('1.0', '2.0'); // -1

get(string $key, mixed $default = null): mixed

Section titled “get(string $key, mixed $default = null): mixed”

Get configuration value.

$value = ConfigHelper::get('app.name', 'default');

Check if config exists.

if (ConfigHelper::has('database.host')) {
// ...
}

Set configuration value.

ConfigHelper::set('app.debug', true);

get(array $data, string $path, mixed $default = null): mixed

Section titled “get(array $data, string $path, mixed $default = null): mixed”

Get value at path.

$value = DotPathHelper::get($data, 'user.name');

set(array &$data, string $path, mixed $value): void

Section titled “set(array &$data, string $path, mixed $value): void”

Set value at path.

DotPathHelper::set($data, 'user.name', 'John');

Check if path exists.

if (DotPathHelper::has($data, 'user.email')) {
// ...
}

Remove value at path.

DotPathHelper::unset($data, 'user.password');

Deep clone object.

$clone = ObjectHelper::deepClone($object);

Convert object to array.

$array = ObjectHelper::toArray($object);

fromArray(array $data, string $class): object

Section titled “fromArray(array $data, string $class): object”

Create object from array.

$object = ObjectHelper::fromArray($data, User::class);

getProperty(object $object, string $property): mixed

Section titled “getProperty(object $object, string $property): mixed”

Get property value.

$value = ObjectHelper::getProperty($object, 'name');

setProperty(object $object, string $property, mixed $value): void

Section titled “setProperty(object $object, string $property, mixed $value): void”

Set property value.

ObjectHelper::setProperty($object, 'name', 'John');