Skip to content
/ luigi Public

Need to generate PHP code? Luigi does the plumbing!

License

Notifications You must be signed in to change notification settings

ju1ius/luigi

Repository files navigation

ju1ius/luigi

codecov

Need to generate PHP code? Luigi does the plumbing!

Installation

composer require ju1ius/luigi

Basic usage

use ju1ius\Luigi\CodeBuilder;

$code = CodeBuilder::create();
// The `raw` method adds verbatim code
$code->raw("return [\n");
// The `indent` method increases the indent level
$code->indent();
// The `write` does the same as `raw` but respects the indent level
$code->write("42,\n");
// The `writeln` method does the same as `write`, but adds a newline character after each argument.
$code->writeln('33,', '66,');
// The `dedent` method decreases the indent level
$code->dedent();
$code->writeln('];');
// CodeBuilder implements the `Stringable` interface
echo $code;

This is the expected output:

return [
    42,
    33,
    66,
];

About

Need to generate PHP code? Luigi does the plumbing!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages