Library
Class

Library\Helper\Code

class Code

Code helper

As for all helpers, all methods are statics.

For convenience, the best practice is to use:

use Library\Helper\Code as CodeHelper;

Constants

NAMESPACE_SEPARATOR

COMPOSER_AUTOLOADER_CLASSNAME

COMPOSER_COMMON_NAMESPACES_AUTOLOADER

Methods

static string getPropertyName(string $name)

Transforms a property name from CamelCase to underscored

static string getPropertyMethodName(string $name)

Transform a property name from underscored to CamelCase used in magic method names

static bool impelementsInterface(string|object $class_name, string $interface_name)

Check if a class implements a certain interface

static bool implementsInterface(string|object $class_name, string $interface_name)

Check if a class implements a certain interface

static bool extendsClass(string|object $class_name, string $mother_name)

Check if a class extends a certain class

static bool isClassInstance(object $object, string $class_name)

Check if a an object is an instance of a class

static bool namespaceExists(string $namespace)

Test if a namespace can be found in declared classes or via Composer autoloader if so This method will search concerned namespace in PHP declared classes namespaces and, if found, in a Composer namespaces mapping usually stored in vendor/composer/autoload_namespaces.php, searching for a directory that should contains the nameapace following the FIG standards.

static mixed fetchArguments(string $method_name = null, mixed $arguments = null, string $class_name = null, array $logs = array())

Launch a function or class's method fetching it arguments according to its declaration

static mixed organizeArguments(string $method_name = null, mixed $arguments = null, string $class_name = null, array $logs = array())

Organize an array of arguments to pass to a function or class's method according to its declaration

static string dumpClosure(Closure $c)

Details

at line 50
static public string getPropertyName(string $name)

Transforms a property name from CamelCase to underscored

Parameters

string $name The property name to transform

Return Value

string The transformed property name

See also

Library\Helper\Text::fromCamelCase()

at line 62
static public string getPropertyMethodName(string $name)

Transform a property name from underscored to CamelCase used in magic method names

Parameters

string $name The property name to transform

Return Value

string The transformed property name

See also

Library\Helper\Text::toCamelCase()

at line 74
static public bool impelementsInterface(string|object $class_name, string $interface_name)

Check if a class implements a certain interface

Parameters

string|object $class_name The class name to test or a full object of this class
string $interface_name The interface name to test

Return Value

bool

at line 87
static public bool implementsInterface(string|object $class_name, string $interface_name)

Check if a class implements a certain interface

Parameters

string|object $class_name The class name to test or a full object of this class
string $interface_name The interface name to test

Return Value

bool

at line 107
static public bool extendsClass(string|object $class_name, string $mother_name)

Check if a class extends a certain class

Parameters

string|object $class_name The class name to test or a full object of this class
string $mother_name The class name to extend

Return Value

bool

at line 126
static public bool isClassInstance(object $object, string $class_name)

Check if a an object is an instance of a class

Parameters

object $object
string $class_name

Return Value

bool

at line 161
static public bool namespaceExists(string $namespace)

Test if a namespace can be found in declared classes or via Composer autoloader if so This method will search concerned namespace in PHP declared classes namespaces and, if found, in a Composer namespaces mapping usually stored in vendor/composer/autoload_namespaces.php, searching for a directory that should contains the nameapace following the FIG standards.

Parameters

string $namespace

Return Value

bool

at line 226
static public mixed fetchArguments(string $method_name = null, mixed $arguments = null, string $class_name = null, array $logs = array())

Launch a function or class's method fetching it arguments according to its declaration

Parameters

string $method_name The method name
mixed $arguments A set of arguments to fetch
string $class_name The class name
array $logs Will be filled with indexes miss with missing required arguments and rest with unused $arguments - Passed by reference

Return Value

mixed

Exceptions

InvalidArgumentException if the method is not callable

at line 258
static public mixed organizeArguments(string $method_name = null, mixed $arguments = null, string $class_name = null, array $logs = array())

Organize an array of arguments to pass to a function or class's method according to its declaration

Undefined arguments will be fetched with their default value if available or null otherwise.

If $arguments is not an array, the method will search for the first argument with no default value and define it on the $arguments value.

Parameters

string $method_name The method name
mixed $arguments A set of arguments to fetch
string $class_name The class name
array $logs Will be filled with indexes miss with missing required arguments and rest with unused $arguments - Passed by reference

Return Value

mixed

at line 336
static public string dumpClosure(Closure $c)

Parameters

Closure $c

Return Value

string

See also

<http://www.metashock.de/2013/05/dump-source-code-of-closure-in-php/>