PhpSpec\Console\ConsoleIO::getBlockWidth PHP Method

getBlockWidth() public method

public getBlockWidth ( ) : integer
return integer
    public function getBlockWidth()
    {
        $width = self::COL_DEFAULT_WIDTH;
        if ($this->consoleWidth && $this->consoleWidth - 10 > self::COL_MIN_WIDTH) {
            $width = $this->consoleWidth - 10;
        }
        if ($width > self::COL_MAX_WIDTH) {
            $width = self::COL_MAX_WIDTH;
        }
        return $width;
    }

Usage Example

コード例 #1
0
ファイル: ConsoleFormatter.php プロジェクト: phpspec/phpspec
 /**
  * @param ExampleEvent $event
  * @param string $type
  */
 protected function printSpecificException(ExampleEvent $event, $type)
 {
     $title = str_replace('\\', DIRECTORY_SEPARATOR, $event->getSpecification()->getTitle());
     $message = $this->getPresenter()->presentException($event->getException(), $this->io->isVerbose());
     foreach (explode("\n", wordwrap($title, $this->io->getBlockWidth(), "\n", true)) as $line) {
         $this->io->writeln(sprintf('<%s-bg>%s</%s-bg>', $type, str_pad($line, $this->io->getBlockWidth()), $type));
     }
     $this->io->writeln(sprintf('<lineno>%4d</lineno>  <%s>- %s</%s>', $event->getExample()->getLineNumber(), $type, $event->getExample()->getTitle(), $type));
     $this->io->writeln(sprintf('<%s>%s</%s>', $type, lcfirst($message), $type), 6);
     $this->io->writeln();
 }