sweetchuck/robo-stringy

Exposes Stringy string manipulation methods

Installs: 97 024

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 1

Type:robo-tasks

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

This package is auto-updated.

Last update: 2024-12-06 20:14:31 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