Descriptors

Writing Descriptors

All descriptors needs to extend the abstract class Authanram\Generators\Descriptor and must define the methods path and fill.

namespace Projecrt\Descriptors;

use Authanram\Generators\Descriptor;
use Authanram\Generators\Input;
use Illuminate\Support\Stringable;

final class ExampleDescriptor extends Descriptor
{
    public static function path(): string
    {
        return __DIR__.'/../stubs/test.stub';
    }

    /** @return array<string, Stringable|string> */
    public static function fill(Input $input): array
    {
        return [
            'second' => $input->get('second'),
            'fourth' => $input->get('fourth'),
        ];
    }
}

path

The method path expects one parameter of type string, defining the path the template should be read from.

fill

The method fill expects one parameter of type callable, used to transform the input before it will be used to replace the template-variables with. It will receive one parameter of type \Authanram\Generators\Input.

To get in-depth information, head over to the section Fill Callback.