承接 elaberino/symfony-style-verbose 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elaberino/symfony-style-verbose

最新稳定版本:1.2.2

Composer 安装命令:

composer require elaberino/symfony-style-verbose

包简介

Add methods to SymfonyStyle to only create output when verbosity flags are set

README 文档

README

This class generates new methods for each output method of symfony style, which only create output based on the defined verbositoy level, e.g. for title, titleIfVerbose(), titleIfVeryVerbose() and titleIfDebug().

The idea is to reduce complexity, if you need output only on some verbosity level.

Example

Before:

$io = new SymfonyStyle($input, $output);

try {
    if ($output->isVerbose()) {
        $io->title('This is my title');
        $io->section('This is my section');
    }
    
    //do some stuff here
    
    if ($output->isVerbose()) {
        $io->section('Get objects');
        $io->progressStart(count($objects));
    }
    $objects = $this->repository->findBy(['active' => true]);
    
    foreach ($objects as $object) {
        //do something with the object
        if ($output->isVerbose()) {
            $io->progressAdvance();
        }
    }
    
    if ($output->isVerbose()) {
        $io->progressFinish();
        $io->success('All objects handled');
    } 
} catch (Throwable $throwable) {
    if ($output->isVerbose()) {
        $io->error('Error while handling products');
    }
    return Command::FAILURE;
}

return Command::SUCCESS;

After:

$io = new SymfonyStyleVerbose($input, $output);

try {
    $io->titleIfVerbose('This is my title');
    $io->sectionIfVerbose('This is my section');
    
    //do some stuff here
    
    $io->sectionIfVerbose('Get objects');
    $io->progressStartIfVerbose(count($objects));
    $objects = $this->repository->findBy(['active' => true]);
        
    foreach ($objects as $object) {
        //do something with the object
        $io->progressAdvanceIfVerbose();
    }
    
    $io->progressFinishIfVerbose();
    $io->successIfVerbose('All objects handled');
} catch (Throwable $throwable) {
    $io->errorIfVerbose($throwable->getMessage());
    
    return Command::FAILURE;
}

return Command::SUCCESS;

Rector Rules

There are rector rules which can make the changes like in the example for you. Go to the Rules Overview to see the rules details.

There ist also a SetList which combines all existing rules.

    $rectorConfig->sets([
        \Elaberino\SymfonyStyleVerbose\Utils\Rector\Set\SymfonyStyleVerboseSetList::CHANGE_OUTPUT,
    ]);

统计信息

  • 总下载量: 1.7k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-03