Classes helpers

List of functions that works for PHP classes.

class_namespace

Gets the namespace from class or object.

$class = App\Http\Controllers\MyController::class;

\OpenSoutheners\ExtendedPhp\Classes\class_namespace($class);
// 'App\Http\Controllers'

class_implement

Similarly than PHP's class_implements but finding a specific interface implemented on the object or class given.

class MyClass implements MyInterface {}

\OpenSoutheners\ExtendedPhp\Classes\class_implement(MyClass::class, MyInterface::class);
// true

class_use

Similarly than PHP's class_uses but finding a specific trait used on the object or class given.

class MyClass implements MyInterface {}

\OpenSoutheners\ExtendedPhp\Classes\class_use(MyClass::class, MyTrait::class);
// false

call

This is specially useful to get types using PHP generics types. Otherwise PHP's array callable or call_user_func_array should be used instead.

Call to the specified public method from class string or object with optional given arguments array.

call_static

Shortcut for `call` function used for call public static methods only.

class_from

Gets class string from object or class. Similarly to PHP's get_class but this one handles whenever string is sent.

Last updated