sweetchuck/robo-stringy

Exposes Stringy string manipulation methods

Installs: 97 011

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 0

Type:robo-tasks

v0.1.0 2020-01-01 21:00 UTC

This package is auto-updated.

Last update: 2024-09-20 02:03:21 UTC


README

CircleCI codecov

This Robo task is useful when you need to do string manipulation in a \Robo\State\Data.

Install

composer require sweetchuck/robo-stringy

Task - taskStringy()

<?php

class RoboFile extends \Robo\Tasks
{
    use \Sweetchuck\Robo\Stringy\StringyTaskLoader;
    
    /**
     * @command stringy:simple
     */
    public function cmdStringySimple(string $text = 'Hello', string $suffix = 'World')
    {
        return $this
            ->collectionBuilder()
            ->addTask(
                $this
                    ->taskStringy()
                    ->setString($text)
                    ->callIsUpperCase()
                    ->callAppend(" $suffix")
                    ->callUnderscored()
            )
            ->addCode(function (\Robo\State\Data $data): int {
                $output = $this->output();
                $output->writeln('Is upper case: ' . var_export($data['stringy.isUpperCase'], true));
                $output->writeln("Result: {$data['stringy']}");

                return 0;
            });
    }
}

Run vendor/bin/robo stringy:simple
Output:

Is upper case: false
Result: hello_world

Run vendor/bin/robo stringy:simple FOO
Output:

Is upper case: true
Result: f_o_o_world