sweetchuck/robo-string

公开了来自 symfony/string 包的字符串操作方法

安装: 257

依赖者: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:robo-tasks

3.x-dev 2024-08-20 13:32 UTC

This package is auto-updated.

Last update: 2024-09-20 13:43:51 UTC


README

CircleCI codecov

此Robo任务在需要在对 \Robo\State\Data 进行字符串操作时非常有用。

安装

composer require sweetchuck/robo-string

任务 - taskStringUnicode()

<?php

declare(strict_types = 1);

use Robo\Tasks;
use Robo\State\Data as StateData;
use Sweetchuck\Robo\String\StringTaskLoader;

class RoboFileExample extends Tasks
{
    use StringTaskLoader;

    /**
     * @command string:simple
     */
    public function cmdStringSimpleExecute(string $string = 'Hello', string $suffix = 'World')
    {
        return $this
            ->collectionBuilder()
            ->addTask(
                $this
                    ->taskStringUnicode()
                    ->setString($string)
                    ->callIsEmpty()
                    ->callAppend(" $suffix")
                    ->callSnake()
            )
            ->addCode(function (StateData $data): int {
                $output = $this->output();
                $output->writeln('Is empty: ' . var_export($data['string.isEmpty'], true));
                $output->writeln("Snake: {$data['string.snake']}");
                $output->writeln("Result: {$data['string']}");

                return 0;
            });
    }
}

运行 vendor/bin/robo string:simple
输出

Is empty: false
Snake: hello_world
Result: hello_world