当前位置: 首页>>代码示例>>PHP>>正文


PHP Text::wrapBlock方法代码示例

本文整理汇总了PHP中Cake\Utility\Text::wrapBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::wrapBlock方法的具体用法?PHP Text::wrapBlock怎么用?PHP Text::wrapBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Utility\Text的用法示例。


在下文中一共展示了Text::wrapBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testWrapBlockIndentWithMultibyte

    /**
     * test wrapBlock() indenting with multibyte caracters
     *
     * @return void
     */
    public function testWrapBlockIndentWithMultibyte()
    {
        $text = 'This is the song that never ends. 这是永远不会结束的歌曲。 This is the song that never ends.';
        $result = Text::wrapBlock($text, ['width' => 33, 'indent' => " → ", 'indentAt' => 1]);
        $expected = <<<TEXT
This is the song that never ends.
 → 这是永远不会结束的歌曲。 This is the song
 → that never ends.
TEXT;
        $this->assertTextEquals($expected, $result);
    }
开发者ID:Slayug,项目名称:castor,代码行数:16,代码来源:TextTest.php

示例2: text

 /**
  * Get the help as formatted text suitable for output on the command line.
  *
  * @param int $width The width of the help output.
  * @return string
  */
 public function text($width = 72)
 {
     $parser = $this->_parser;
     $out = [];
     $description = $parser->description();
     if (!empty($description)) {
         $out[] = Text::wrap($description, $width);
         $out[] = '';
     }
     $out[] = '<info>Usage:</info>';
     $out[] = $this->_generateUsage();
     $out[] = '';
     $subcommands = $parser->subcommands();
     if (!empty($subcommands)) {
         $out[] = '<info>Subcommands:</info>';
         $out[] = '';
         $max = $this->_getMaxLength($subcommands) + 2;
         foreach ($subcommands as $command) {
             $out[] = Text::wrapBlock($command->help($max), ['width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1]);
         }
         $out[] = '';
         $out[] = sprintf('To see help on a subcommand use <info>`cake %s [subcommand] --help`</info>', $parser->command());
         $out[] = '';
     }
     $options = $parser->options();
     if (!empty($options)) {
         $max = $this->_getMaxLength($options) + 8;
         $out[] = '<info>Options:</info>';
         $out[] = '';
         foreach ($options as $option) {
             $out[] = Text::wrapBlock($option->help($max), ['width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1]);
         }
         $out[] = '';
     }
     $arguments = $parser->arguments();
     if (!empty($arguments)) {
         $max = $this->_getMaxLength($arguments) + 2;
         $out[] = '<info>Arguments:</info>';
         $out[] = '';
         foreach ($arguments as $argument) {
             $out[] = Text::wrapBlock($argument->help($max), ['width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1]);
         }
         $out[] = '';
     }
     $epilog = $parser->epilog();
     if (!empty($epilog)) {
         $out[] = Text::wrap($epilog, $width);
         $out[] = '';
     }
     return implode("\n", $out);
 }
开发者ID:rlugojr,项目名称:cakephp,代码行数:57,代码来源:HelpFormatter.php


注:本文中的Cake\Utility\Text::wrapBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。