sweetchuck / robo-string
公开了来自 symfony/string 包的字符串操作方法
3.x-dev
2024-08-20 13:32 UTC
Requires
- php: >=8.3
- consolidation/robo: ^5.0
- symfony/string: ^5.0 || ^6.0 || ^7.0
Requires (Dev)
- ext-json: *
- codeception/codeception: ^5.0
- codeception/module-asserts: ^3.0
- nuvoleweb/robo-config: 4.x-dev
- phpstan/phpstan: ^1.11
- squizlabs/php_codesniffer: ^3.5
- sweetchuck/codeception-module-robo-task-runner: 4.x-dev
- sweetchuck/git-hooks: 2.x-dev
- sweetchuck/robo-git: 4.x-dev
- sweetchuck/robo-phpcs: 4.x-dev
- sweetchuck/robo-phpstan: 3.x-dev
- symfony/error-handler: ^5.0 || ^6.0 || ^7.0
- symfony/finder: ^5.0 || ^6.0 || ^7.0
- symfony/yaml: ^5.0 || ^6.0 || ^7.0
README
此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