class MixedType (View source)

Methods

static array
toArray(mixed $argument)

Converts a value to an array containing this value unless it is an array.

static mixed
value(mixed $entity, array $arguments = [], string $method = '__invoke', callable $instantiator = 'static::instantiate')

Executes a value depending on what type it is and returns the result Callable: call; return result Instance: call method; return result Class: instantiate; call method; return result Other: return value without taking any action

static boolean
isClass(mixed $class_name)

Check if a value is a valid class name

static object
instantiate(string $class_name)

Create a new instance of the given class.

static string
normalizePath(string $path, string $slash = DIRECTORY_SEPARATOR)

Normalize a path's slashes according to the current OS.

static string
addTrailingSlash(string $path, string $slash = DIRECTORY_SEPARATOR)

Ensure path has a trailing slash.

static string
removeTrailingSlash(string $path, string $slash = DIRECTORY_SEPARATOR)

Ensure path does not have a trailing slash.

Details

static array toArray(mixed $argument)

Converts a value to an array containing this value unless it is an array.

This will not convert objects like (array) casting does.

Parameters

mixed $argument

Return Value

array

static mixed value(mixed $entity, array $arguments = [], string $method = '__invoke', callable $instantiator = 'static::instantiate')

Executes a value depending on what type it is and returns the result Callable: call; return result Instance: call method; return result Class: instantiate; call method; return result Other: return value without taking any action

Parameters

mixed $entity
array $arguments
string $method
callable $instantiator

Return Value

mixed

static boolean isClass(mixed $class_name)

Check if a value is a valid class name

Parameters

mixed $class_name

Return Value

boolean

static object instantiate(string $class_name)

Create a new instance of the given class.

Parameters

string $class_name

Return Value

object

static string normalizePath(string $path, string $slash = DIRECTORY_SEPARATOR)

Normalize a path's slashes according to the current OS.

Solves mixed slashes that are sometimes returned by WordPress core functions.

Parameters

string $path
string $slash

Return Value

string

static string addTrailingSlash(string $path, string $slash = DIRECTORY_SEPARATOR)

Ensure path has a trailing slash.

Parameters

string $path
string $slash

Return Value

string

static string removeTrailingSlash(string $path, string $slash = DIRECTORY_SEPARATOR)

Ensure path does not have a trailing slash.

Parameters

string $path
string $slash

Return Value

string