/**
  * Генерирует листинг участка кода
  *
  * @param array $block
  * @param int $num
  *
  * @return string
  */
 protected function getListing()
 {
     $i = 0;
     $blockCont = '';
     $script = file($this->file);
     $ext = ceil($this->sizeListing / 2);
     $position = $this->line <= $ext ? 0 : $this->line - $ext;
     foreach ($script as $string) {
         ++$i;
         if ($i === $this->line) {
             $lines[] = $this->painter->wrapLine($i, 'error');
         } else {
             $lines[] = $i;
         }
         $blockCont .= $string;
     }
     $lines = array_slice($lines, $position, $this->sizeListing);
     $ext = pathinfo($this->file)['extension'];
     if ($ext === 'tpl') {
         $total = $this->painter->highlightStringTpl($blockCont, $position, $this->sizeListing);
     } else {
         $total = $this->painter->highlightString($blockCont, $position, $this->sizeListing);
     }
     $data = ['num' => null, 'arguments' => null, 'lines' => [$lines], 'total' => $total];
     return $this->view->createBlock($data);
 }
 /**
  * Генерирует листинг участка кода
  *
  * @param array $block
  * @param int $num
  *
  * @return string
  */
 protected function prepareBlock($block, $num = false)
 {
     $i = 0;
     $blockCont = '';
     $line = !empty($block['line']) ? $block['line'] : null;
     if (!empty($block['file'])) {
         $this->file = $block['file'];
         $this->line = $block['line'];
         $script = file($block['file']);
     } else {
         return null;
     }
     $arguments = $this->prepareValue(@$block['args']);
     $ext = ceil($this->sizeListing / 2);
     $position = $line <= $ext ? 0 : $line - $ext;
     foreach ($script as $string) {
         ++$i;
         if ($this->mainBlock && $i == $line) {
             $lines[] = $this->painter->wrapLine($i, 'error');
         } elseif ($i == $line) {
             $lines[] = $this->painter->wrapLine($i, 'trace');
         } else {
             $lines[] = $i;
         }
         $blockCont .= $string;
     }
     $lines = array_slice($lines, $position, $this->sizeListing);
     if (!$this->exception && $num === false) {
         $arguments = 'null';
     }
     $ext = pathinfo($this->file)['extension'];
     if ($ext === 'tpl') {
         $total = $this->painter->highlightStringTpl($blockCont, $position, $this->sizeListing);
     } else {
         $total = $this->painter->highlightString($blockCont, $position, $this->sizeListing);
     }
     $data = ['num' => $num, 'arguments' => $this->painter->highlightVar($arguments), 'lines' => [$lines], 'total' => $total];
     return $this->view->createBlock($data);
 }