2017 © Pedro Peláez
 

library robo-stringy

Template to create a new Robo task.

image

sweetchuck/robo-stringy

Template to create a new Robo task.

  • Thursday, May 31, 2018
  • by Sweetchuck
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 50 % Grown

The README.md

Robo Stringy

CircleCI codecov, (*1)

This Robo task is useful when you need to do string manipulation in a \Robo\State\Data., (*2)

Install

composer require sweetchuck/robo-stringy, (*3)

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:, (*4)

Is upper case: false
> Result: hello_world

Run vendor/bin/robo stringy:simple FOO
Output:, (*5)

Is upper case: true
> Result: f_o_o_world

The Versions