Hoa central
Pager.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Console\Chrome;
38 
39 use Hoa\Console;
40 
52 class Pager
53 {
59  const LESS = 'less';
60 
66  const MORE = 'more';
67 
68 
69 
77  public static function less($output, $mode)
78  {
79  return self::pager($output, $mode, self::LESS);
80  }
81 
89  public static function more($output, $mode)
90  {
91  return self::pager($output, $mode, self::MORE);
92  }
93 
102  public static function pager($output, $mode, $type = null)
103  {
104  static $process = null;
105 
106  if ($mode & PHP_OUTPUT_HANDLER_START) {
107  $pager
108  = null !== $type
110  : (isset($_ENV['PAGER']) ? $_ENV['PAGER'] : null);
111 
112  if (null === $pager) {
113  return $output;
114  }
115 
116  $process = new Console\Processus(
117  $pager,
118  null,
119  [['pipe', 'r']]
120  );
121  $process->open();
122  }
123 
124  $process->writeAll($output);
125 
126  if ($mode & PHP_OUTPUT_HANDLER_FINAL) {
127  $process->close();
128  }
129 
130  return null;
131  }
132 }
static pager($output, $mode, $type=null)
Definition: Pager.php:102
static less($output, $mode)
Definition: Pager.php:77
static more($output, $mode)
Definition: Pager.php:89
static locate($binary)
Definition: Processus.php:1133