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


PHP String::wrap方法代码示例

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


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

示例1: wrapText

 /**
  * Wrap a block of text.
  * Allows you to set the width, and indenting on a block of text.
  *
  * ### Options
  *
  * - `width` The width to wrap to. Defaults to 72
  * - `wordWrap` Only wrap on words breaks (spaces) Defaults to true.
  * - `indent` Indent the text with the string provided. Defaults to null.
  *
  * @param string $text Text the text to format.
  * @param string|integer|array $options Array of options to use, or an integer to wrap the text to.
  * @return string Wrapped / indented text
  * @see String::wrap()
  * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText
  */
 public function wrapText($text, $options = array())
 {
     return String::wrap($text, $options);
 }
开发者ID:4Queen,项目名称:php-buildpack,代码行数:20,代码来源:Shell.php

示例2: testWrapIndent

    /**
     * test wrap() indenting
     *
     * @return void
     */
    public function testWrapIndent()
    {
        $text = 'This is the song that never ends. This is the song that never ends. This is the song that never ends.';
        $result = String::wrap($text, array('width' => 33, 'indent' => "\t", 'indentAt' => 1));
        $expected = <<<TEXT
This is the song that never ends.
\tThis is the song that never ends.
\tThis is the song that never ends.
TEXT;
        $this->assertTextEquals($expected, $result);
    }
开发者ID:nabeelio,项目名称:CakePHP-Base,代码行数:16,代码来源:StringTest.php

示例3: bake

 /**
  * Looks for a skeleton template of a Cake application,
  * and if not found asks the user for a path. When there is a path
  * this method will make a deep copy of the skeleton to the project directory.
  *
  * @param string $path Project path
  * @param string $skel Path to copy from
  * @param string $skip array of directories to skip when copying
  * @return mixed
  */
 public function bake($path, $skel = null, $skip = array('empty'))
 {
     if (!$skel && !empty($this->params['skel'])) {
         $skel = $this->params['skel'];
     }
     while (!$skel) {
         $skel = $this->in(__d('cake_console', "What is the path to the directory layout you wish to copy?"), null, CAKE . 'Console' . DS . 'Templates' . DS . 'skel');
         if (!$skel) {
             $this->err(__d('cake_console', 'The directory path you supplied was empty. Please try again.'));
         } else {
             while (is_dir($skel) === false) {
                 $skel = $this->in(__d('cake_console', 'Directory path does not exist please choose another:'), null, CAKE . 'Console' . DS . 'Templates' . DS . 'skel');
             }
         }
     }
     $app = basename($path);
     $this->out(__d('cake_console', '<info>Skel Directory</info>: ') . $skel);
     $this->out(__d('cake_console', '<info>Will be copied to</info>: ') . $path);
     $this->hr();
     $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n', 'q'), 'y');
     switch (strtolower($looksGood)) {
         case 'y':
             $Folder = new Folder($skel);
             if (!empty($this->params['empty'])) {
                 $skip = array();
             }
             if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
                 $this->hr();
                 $this->out(__d('cake_console', '<success>Created:</success> %s in %s', $app, $path));
                 $this->hr();
             } else {
                 $this->err(__d('cake_console', "<error>Could not create</error> '%s' properly.", $app));
                 return false;
             }
             foreach ($Folder->messages() as $message) {
                 $this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE);
             }
             return true;
         case 'n':
             unset($this->args[0]);
             $this->execute();
             return false;
         case 'q':
             $this->out(__d('cake_console', '<error>Bake Aborted.</error>'));
             return false;
     }
 }
开发者ID:Vighnesh123,项目名称:book-a-bus,代码行数:57,代码来源:ProjectTask.php

示例4: text

 /**
  * Get the help as formatted text suitable for output on the command line.
  *
  * @param integer $width
  *        	The width of the help output.
  * @return string
  */
 public function text($width = 72)
 {
     $parser = $this->_parser;
     $out = array();
     $description = $parser->description();
     if (!empty($description)) {
         $out[] = String::wrap($description, $width);
         $out[] = '';
     }
     $out[] = __d('cake_console', '<info>Usage:</info>');
     $out[] = $this->_generateUsage();
     $out[] = '';
     $subcommands = $parser->subcommands();
     if (!empty($subcommands)) {
         $out[] = __d('cake_console', '<info>Subcommands:</info>');
         $out[] = '';
         $max = $this->_getMaxLength($subcommands) + 2;
         foreach ($subcommands as $command) {
             $out[] = String::wrap($command->help($max), array('width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1));
         }
         $out[] = '';
         $out[] = __d('cake_console', '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[] = __d('cake_console', '<info>Options:</info>');
         $out[] = '';
         foreach ($options as $option) {
             $out[] = String::wrap($option->help($max), array('width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1));
         }
         $out[] = '';
     }
     $arguments = $parser->arguments();
     if (!empty($arguments)) {
         $max = $this->_getMaxLength($arguments) + 2;
         $out[] = __d('cake_console', '<info>Arguments:</info>');
         $out[] = '';
         foreach ($arguments as $argument) {
             $out[] = String::wrap($argument->help($max), array('width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1));
         }
         $out[] = '';
     }
     $epilog = $parser->epilog();
     if (!empty($epilog)) {
         $out[] = String::wrap($epilog, $width);
         $out[] = '';
     }
     return implode("\n", $out);
 }
开发者ID:julkar9,项目名称:gss,代码行数:58,代码来源:HelpFormatter.php

示例5: array

	<h4>
		<?php 
    echo $HTML->link($Comment->BlogPost->detailPageUri() . '#Comments', $Comment->BlogPost->get('headline'));
    ?>
	</h4>
	<?php 
}
?>
	<h3>
		<?php 
echo $this->element('gravatar', array('email' => $Comment->get('email'), 'size' => $avatarSize));
echo date(__('d.m.Y H:i'), $Comment->created) . '<br />';
if ($Comment->url) {
    echo $HTML->link('http://' . $Comment->url, $Comment->get('name'), array('rel' => 'external'));
} else {
    echo $Comment->get('name');
}
?>
	</h3><br />
	<?php 
$text = $Comment->text;
$text = Sanitizer::html($text);
$text = nl2br($text);
$text = Text::autoURLs($text);
$text = String::wrap($text, 55, true);
if (isset($truncated)) {
    $text = String::truncate($text, $truncated !== true ? $truncated : 120, '…');
}
echo Sanitizer::html($text);
?>
</li>
开发者ID:Ephigenia,项目名称:harrison,代码行数:31,代码来源:comment.php

示例6: _bake

 /**
  * Looks for a skeleton template of a Cake application,
  * and if not found asks the user for a path. When there is a path
  * this method will make a deep copy of the skeleton to the project directory.
  *
  * @param string $path Project path
  * @param string $skel Path to copy from
  * @param string $skip array of directories to skip when copying
  * @return boolean
  */
 protected function _bake($path, $skel, $skip = array())
 {
     $Folder = new Folder($skel);
     $app = basename($path);
     if (!$Folder->copy(array('to' => $path, 'skip' => $skip))) {
         $this->err(__d('cake_console', "<error>Could not create</error> '%s' properly.", $app));
         return false;
     }
     foreach ($Folder->messages() as $message) {
         $this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE);
     }
     return true;
 }
开发者ID:rikkeisoft,项目名称:cakephp2,代码行数:23,代码来源:ProjectShell.php

示例7: bake

 /**
  * Looks for a skeleton template of a Cake application,
  * and if not found asks the user for a path. When there is a path
  * this method will make a deep copy of the skeleton to the project directory.
  * A default home page will be added, and the tmp file storage will be chmod'ed to 0777.
  *
  * @param string $path Project path
  * @param string $skel Path to copy from
  * @param string $skip array of directories to skip when copying
  * @access private
  */
 function bake($path, $skel = null, $skip = array('empty'))
 {
     if (!$skel) {
         $skel = $this->params['skel'];
     }
     while (!$skel) {
         $skel = $this->in(__("What is the path to the directory layout you wish to copy?\nExample: %s", APP, null, ROOT . DS . 'myapp' . DS));
         if ($skel == '') {
             $this->err(__('The directory path you supplied was empty. Please try again.'));
         } else {
             while (is_dir($skel) === false) {
                 $skel = $this->in(__('Directory path does not exist please choose another:'));
             }
         }
     }
     $app = basename($path);
     $this->out(__('<info>Skel Directory</info>: ') . $skel);
     $this->out(__('<info>Will be copied to</info>: ') . $path);
     $this->hr();
     $looksGood = $this->in(__('Look okay?'), array('y', 'n', 'q'), 'y');
     if (strtolower($looksGood) == 'y') {
         $Folder = new Folder($skel);
         if (!empty($this->params['empty'])) {
             $skip = array();
         }
         if ($Folder->copy(array('to' => $path, 'skip' => $skip))) {
             $this->hr();
             $this->out(__('<success>Created:</success> %s in %s', $app, $path));
             $this->hr();
         } else {
             $this->err(__("<error>Could not create</error> '%s' properly.", $app));
             return false;
         }
         foreach ($Folder->messages() as $message) {
             $this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE);
         }
         return true;
     } elseif (strtolower($looksGood) == 'q') {
         $this->out(__('Bake Aborted.'));
     } else {
         $this->execute(false);
         return false;
     }
 }
开发者ID:no2key,项目名称:Web-Framework-Benchmark,代码行数:55,代码来源:project.php

示例8: testWrapIndent

    /**
     * test wrap() indenting
     *
     * @return void
     */
    function testWrapIndent()
    {
        $text = 'This is the song that never ends. This is the song that never ends. This is the song that never ends.';
        $result = String::wrap($text, array('width' => 33, 'indent' => "\t", 'indentAt' => 1));
        $expected = <<<TEXT
This is the song that never ends.
\tThis is the song that never ends.
\tThis is the song that never ends.
TEXT;
    }
开发者ID:robotarmy,项目名称:Phog,代码行数:15,代码来源:string.test.php


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