diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2015-02-05 11:45:26 +0100 |
---|---|---|
committer | Fabio Bas <ctrlaltca@gmail.com> | 2015-02-05 11:45:26 +0100 |
commit | 6dae236ec5528522de472637f9d70a98158b9a5d (patch) | |
tree | 0392bc0afb1f09921810d8b313b1f22b2f360106 /framework/Vendor/PhpShell/PHP/Shell/Extensions/VerbosePrint.php | |
parent | 81efaa0c6acdcd2e36081fed21ad5eac11fad3bc (diff) |
Renamed 3rdparty directory to vendor
Php namespaces can’t begin with a number
Diffstat (limited to 'framework/Vendor/PhpShell/PHP/Shell/Extensions/VerbosePrint.php')
-rw-r--r-- | framework/Vendor/PhpShell/PHP/Shell/Extensions/VerbosePrint.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/framework/Vendor/PhpShell/PHP/Shell/Extensions/VerbosePrint.php b/framework/Vendor/PhpShell/PHP/Shell/Extensions/VerbosePrint.php new file mode 100644 index 00000000..425937c1 --- /dev/null +++ b/framework/Vendor/PhpShell/PHP/Shell/Extensions/VerbosePrint.php @@ -0,0 +1,56 @@ +<?php +class PHP_Shell_Extensions_VerbosePrint implements PHP_Shell_Extension { + protected $opt_verbose = false; + protected $oneshot_verbose = false; + + public function register() { +/* $cmd = PHP_Shell_Commands::getInstance(); + $cmd->registerCommand('#^p #', $this, 'cmdPrint', 'p <var>', 'print the variable verbosly'); + + $opt = PHP_Shell_Options::getInstance(); + $opt->registerOption('verboseprint', $this, 'optSetVerbose'); +*/ + } + + /** + * handle the 'p ' command + * + * set the verbose flag + * + * @return string the pure command-string without the 'p ' command + */ + public function cmdPrint($l) { + $this->oneshot_verbose = true; + + $cmd = substr($l, 2); + + return $cmd; + } + + public function optSetVerbose($key, $val) { + switch($val) { + case "false": + case "on": + case "1": + $this->opt_verbose = true; + default: + $this->opt_verbose = false; + break; + } + } + + /** + * check if we have a verbose print-out + * + * @return bool 1 if verbose, 0 otherwise + */ + public function isVerbose() { + $v = $this->opt_verbose || $this->oneshot_verbose; + + $this->oneshot_verbose = false; + + return $v; + } +} + + |