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


PHP Utils::truncate方法代码示例

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


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

示例1: serve

 /**
  * @return int|null|void
  */
 protected function serve()
 {
     $this->options = $this->input->getOptions();
     $this->gpm = new GPM($this->options['force']);
     $this->displayGPMRelease();
     $this->data = $this->gpm->getRepository();
     $data = $this->filter($this->data);
     $climate = new CLImate();
     $climate->extend('Grav\\Console\\TerminalObjects\\Table');
     if (!$data) {
         $this->output->writeln('No data was found in the GPM repository stored locally.');
         $this->output->writeln('Please try clearing cache and running the <green>bin/gpm index -f</green> command again');
         $this->output->writeln('If this doesn\'t work try tweaking your GPM system settings.');
         $this->output->writeln('');
         $this->output->writeln('For more help go to:');
         $this->output->writeln(' -> <yellow>https://learn.getgrav.org/troubleshooting/common-problems#cannot-connect-to-the-gpm</yellow>');
         die;
     }
     foreach ($data as $type => $packages) {
         $this->output->writeln("<green>" . strtoupper($type) . "</green> [ " . count($packages) . " ]");
         $packages = $this->sort($packages);
         if (!empty($packages)) {
             $table = [];
             $index = 0;
             foreach ($packages as $slug => $package) {
                 $row = ['Count' => $index++ + 1, 'Name' => "<cyan>" . Utils::truncate($package->name, 20, false, ' ', '...') . "</cyan> ", 'Slug' => $slug, 'Version' => $this->version($package), 'Installed' => $this->installed($package)];
                 $table[] = $row;
             }
             $climate->table($table);
         }
         $this->output->writeln('');
     }
     $this->output->writeln('You can either get more informations about a package by typing:');
     $this->output->writeln('    <green>' . $this->argv . ' info <cyan><package></cyan></green>');
     $this->output->writeln('');
     $this->output->writeln('Or you can install a package by typing:');
     $this->output->writeln('    <green>' . $this->argv . ' install <cyan><package></cyan></green>');
     $this->output->writeln('');
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:42,代码来源:IndexCommand.php

示例2: testTruncate

 public function testTruncate()
 {
     $this->assertEquals('engli' . '&hellip;', Utils::truncate('english', 5));
     $this->assertEquals('english', Utils::truncate('english'));
     $this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
     $this->assertEquals('Th' . '&hellip;', Utils::truncate('This is a string to truncate', 2));
     $this->assertEquals('engli' . '...', Utils::truncate('english', 5, true, " ", "..."));
     $this->assertEquals('english', Utils::truncate('english'));
     $this->assertEquals('This is a string to truncate', Utils::truncate('This is a string to truncate'));
     $this->assertEquals('This ', Utils::truncate('This is a string to truncate', 3, true));
     $this->assertEquals('<input ', Utils::truncate('<input type="file" id="file" multiple />', 6, true));
 }
开发者ID:getgrav,项目名称:grav,代码行数:12,代码来源:UtilsTest.php

示例3: testTruncate

 public function testTruncate()
 {
     $this->assertEquals(Utils::truncate('english', 5), 'engli' . '&hellip;');
     $this->assertEquals(Utils::truncate('english'), 'english');
     $this->assertEquals(Utils::truncate('This is a string to truncate'), 'This is a string to truncate');
     $this->assertEquals(Utils::truncate('This is a string to truncate', 2), 'Th' . '&hellip;');
     $this->assertEquals(Utils::truncate('english', 5, true, " ", "..."), 'engli' . '...');
     $this->assertEquals(Utils::truncate('english'), 'english');
     $this->assertEquals(Utils::truncate('This is a string to truncate'), 'This is a string to truncate');
     $this->assertEquals(Utils::truncate('This is a string to truncate', 3, true), 'This ');
 }
开发者ID:nikkialgar,项目名称:grav,代码行数:11,代码来源:UtilsTest.php


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