PHP_Shell
[ class tree: PHP_Shell ] [ index: PHP_Shell ] [ all elements ]

Source for file VerbosePrint.php

Documentation is available at VerbosePrint.php

  1. <?php
  2. class PHP_Shell_Extensions_VerbosePrint implements PHP_Shell_Extension {
  3.     protected $opt_verbose = false;
  4.     protected $oneshot_verbose = false;
  5.  
  6.     public function register({
  7.         $cmd = PHP_Shell_Commands::getInstance();
  8.         $cmd->registerCommand('#^p #'$this'cmdPrint''p <var>''print the variable verbosly');
  9.  
  10.         $opt = PHP_Shell_Options::getInstance();
  11.         $opt->registerOption('verboseprint'$this'optSetVerbose');
  12.  
  13.     }
  14.  
  15.     /**
  16.     * handle the 'p ' command
  17.     *
  18.     * set the verbose flag
  19.     *
  20.     * @return string the pure command-string without the 'p ' command
  21.     */
  22.     public function cmdPrint($l{
  23.         $this->oneshot_verbose = true;
  24.  
  25.         $cmd substr($l2);
  26.  
  27.         return $cmd;
  28.     }
  29.  
  30.     public function optSetVerbose($key$val{
  31.         switch($val{
  32.         case "false":
  33.         case "on":
  34.         case "1":
  35.             $this->opt_verbose = true;
  36.         default:
  37.             $this->opt_verbose = false;
  38.             break;
  39.         }
  40.     }
  41.  
  42.     /**
  43.     * check if we have a verbose print-out
  44.     *
  45.     * @return bool 1 if verbose, 0 otherwise
  46.     */
  47.     public function isVerbose({
  48.         $v $this->opt_verbose || $this->oneshot_verbose;
  49.  
  50.         $this->oneshot_verbose = false;
  51.         
  52.         return $v;
  53.     }
  54. }

Documentation generated on Mon, 11 Mar 2019 14:40:36 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.