# Common

The Common component provides general-purpose tooling.

# Description

DescriptionInterface describes the interface for a class which describe itself.

TIP

Use DescriptionTrait (opens new window) to implement the DescriptionInterface.

use Chevere\Interfaces\Common\DescriptionInterface;
use Chevere\Components\Common\Traits\DescriptionTrait;

class MyDescribedClass implements DescriptionInterface
{
    use DescriptionTrait;

    public function __construct()
    {
        $this->description = $this->getDescription();
    }

    public function getDescription(): string
    {
        return 'I do something';
    }
}

# To Array

ToArrayInterface describes the interface for a class providing an array representation.

use Chevere\Interfaces\Common\ToArrayInterface;

class MyToArrayClass implements ToArrayInterface
{
    private array $array;

    public function toArray(): array
    {
        return $this->array;
    }
}

# To String

ToStringInterface describes the interface for a class providing a string representation.

use Chevere\Interfaces\Common\ToStringInterface;

class MyToStringClass implements ToStringInterface
{
    private string $string;

    public function toString(): string
    {
        return $this->string;
    }
}

Work in progress

  • Attributes