Oihana PHP System

Options uses ReflectionTrait

AbstractYes

Base class for options definitions.

Table of Contents

Properties

$prefix  : string
The default prefix of the options (by default "--").
$__className  : string|null
$__reflection  : Reflection|null

Methods

__construct()  : mixed
Initializes options from an array or object.
__toString()  : string
Returns the string expression of the object.
create()  : Options
Creates a new instance of the called class with optional options.
getClassName()  : string
Returns the short class name of the given object/class.
getConstants()  : array<string|int, mixed>
Returns the list of all constants of the given object/class.
getOptions()  : string
Returns the full options expression with the specific constant definitions.
getPublicProperties()  : array<string|int, mixed>
Internal methods to get the public
getShortName()  : string
Returns the class short name.
hydrate()  : object
Populates an object of the given class with data from the provided array.
jsonSerializeFromPublicProperties()  : array<string|int, mixed>
Invoked to generates the json array serializer array representation from the public properties of the object.

Properties

$prefix

The default prefix of the options (by default "--").

public static string $prefix = \oihana\enums\Char::DOUBLE_HYPHEN

Methods

__construct()

Initializes options from an array or object.

public __construct([array<string|int, mixed>|object|null $init = null ]) : mixed
Parameters
$init : array<string|int, mixed>|object|null = null

__toString()

Returns the string expression of the object.

public __toString() : string
Tags
throws
ReflectionException
Return values
string

create()

Creates a new instance of the called class with optional options.

public static create([array<string|int, mixed>|Options|null $options = null ]) : Options
Parameters
$options : array<string|int, mixed>|Options|null = null
Return values
Options

getClassName()

Returns the short class name of the given object/class.

public getClassName(object|string $class) : string
Parameters
$class : object|string

The object or the classname reference.

Return values
string

getConstants()

Returns the list of all constants of the given object/class.

public getConstants(object|string $class) : array<string|int, mixed>
Parameters
$class : object|string

The object or the classname reference.

Tags
throws
ReflectionException
Return values
array<string|int, mixed>

getOptions()

Returns the full options expression with the specific constant definitions.

public getOptions(string $clazz) : string
Parameters
$clazz : string
Tags
throws
InvalidArgumentException
throws
ReflectionException
Return values
string

getPublicProperties()

Internal methods to get the public

public getPublicProperties(object|string $class) : array<string|int, mixed>
Parameters
$class : object|string

The object or the classname reference.

Tags
throws
ReflectionException
Return values
array<string|int, mixed>

getShortName()

Returns the class short name.

public getShortName(object|string $class) : string
Parameters
$class : object|string

The object or the classname reference.

Tags
throws
ReflectionException
Return values
string

hydrate()

Populates an object of the given class with data from the provided array.

public hydrate(array<string|int, mixed> $thing, string $class) : object
Parameters
$thing : array<string|int, mixed>

The data array used to hydrate the object.

$class : string

The classname of the object to be hydrated.

Tags
throws
ReflectionException
Return values
object

The hydrated object of the given class.

jsonSerializeFromPublicProperties()

Invoked to generates the json array serializer array representation from the public properties of the object.

public jsonSerializeFromPublicProperties(object|string $class[, bool $reduce = false ]) : array<string|int, mixed>
Parameters
$class : object|string

The classname of the object to be serialized.

$reduce : bool = false

Indicates if the returned associative array is compressed, the null properties are removed.

Tags
throws
ReflectionException
Return values
array<string|int, mixed>

        
On this page

Search results