> For the complete documentation index, see [llms.txt](https://docs.opensoutheners.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.opensoutheners.com/home/extended-php/classes-helpers.md).

# Classes helpers

List of functions that works for PHP classes.

## class\_namespace

Gets the namespace from class or object.

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

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

## class\_implement

Similarly than PHP's [`class_implements`](https://www.php.net/manual/en/function.class-implements.php) but finding a specific interface implemented on the object or class given.

```php
class MyClass implements MyInterface {}

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

## class\_use

Similarly than PHP's [`class_uses`](https://www.php.net/manual/en/function.class-uses.php) but finding a specific trait used on the object or class given.

```php
class MyClass implements MyInterface {}

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

## call

{% hint style="info" %}
This is specially useful to get types using PHP generics types. Otherwise PHP's [array callable](https://www.php.net/manual/en/functions.first_class_callable_syntax.php) or [`call_user_func_array`](https://www.php.net/manual/en/function.call-user-func-array.php) should be used instead.
{% endhint %}

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

```php
class MyClass implements MyInterface
{
    public static function myStaticMethod(string $name)
    {
        return "greetings {$name}!";
    }

    public function myMethod(string $name)
    {
        return "hello {$name}!";
    }
}

\OpenSoutheners\ExtendedPhp\Classes\call(MyClass::class, 'myStaticMethod', ['user'], true);
// 'greetings user!'

\OpenSoutheners\ExtendedPhp\Classes\call(MyClass::class, 'myMethod', ['world']);
// 'hello world!'
```

## call\_static

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

```php
class MyClass implements MyInterface
{
    public static function myStaticMethod(string $name)
    {
        return "greetings {$name}!";
    }
}

\OpenSoutheners\ExtendedPhp\Classes\call_static(MyClass::class, 'myStaticMethod', ['user']);
// 'greetings user!'
```

## class\_from

Gets class string from object or class. Similarly to PHP's [`get_class`](https://www.php.net/manual/en/function.get-class) but this one handles whenever string is sent.

```php
$class = App\Http\Controllers\MyController::class;
$classInstance = new $class;

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

\OpenSoutheners\ExtendedPhp\Classes\class_from($classInstance);
// 'App\Http\Controllers\MyController'
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.opensoutheners.com/home/extended-php/classes-helpers.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
