@@ -1,15 +1,15 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | function kill() { |
| 4 | - return call_user_func_array("\\PHP\\Utils::kill", func_get_args()); |
|
| 4 | + return call_user_func_array("\\PHP\\Utils::kill", func_get_args()); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | function dump_sql($sSql) { |
| 8 | - return \PHP\Utils::dump_sql($sSql); |
|
| 8 | + return \PHP\Utils::dump_sql($sSql); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | function kill_sql($sSql) { |
| 12 | 12 | |
| 13 | - \PHP\Utils::dump_sql($sSql); |
|
| 14 | - die("FIM SQL"); |
|
| 13 | + \PHP\Utils::dump_sql($sSql); |
|
| 14 | + die("FIM SQL"); |
|
| 15 | 15 | } |
@@ -3,26 +3,26 @@ |
||
| 3 | 3 | |
| 4 | 4 | class Log { |
| 5 | 5 | |
| 6 | - private static $oInstance; |
|
| 6 | + private static $oInstance; |
|
| 7 | 7 | |
| 8 | - private $oLogger; |
|
| 8 | + private $oLogger; |
|
| 9 | 9 | |
| 10 | - private function __construct() { |
|
| 10 | + private function __construct() { |
|
| 11 | 11 | |
| 12 | 12 | $this->oLogger = new \Monolog\Logger("PHPUtils"); |
| 13 | 13 | $this->oLogger->pushHandler( new \Monolog\Handler\StreamHandler("/tmp/PHPUtils.log") ); |
| 14 | 14 | $this->oLogger->pushHandler( new \Monolog\Handler\ChromePHPHandler() ); |
| 15 | 15 | $this->oLogger->pushHandler( new \Monolog\Handler\FirePHPHandler() ); |
| 16 | - } |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public function log() {} |
|
| 18 | + public function log() {} |
|
| 19 | 19 | |
| 20 | - public function debug() { } |
|
| 20 | + public function debug() { } |
|
| 21 | 21 | |
| 22 | - public function warn() { } |
|
| 22 | + public function warn() { } |
|
| 23 | 23 | |
| 24 | - public function info() { } |
|
| 24 | + public function info() { } |
|
| 25 | 25 | |
| 26 | - public function error() { } |
|
| 26 | + public function error() { } |
|
| 27 | 27 | |
| 28 | 28 | } |
@@ -19,6 +19,9 @@ |
||
| 19 | 19 | return call_user_func_array('parent::__construct', func_get_args()); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | + /** |
|
| 23 | + * @param string $type |
|
| 24 | + */ |
|
| 22 | 25 | public function sendLog($type, $key, $value = null, array $backtrace ) { |
| 23 | 26 | |
| 24 | 27 | $logger = $this->logger; |
@@ -3,23 +3,23 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class ArrayDebugger extends \ArrayObject { |
| 5 | 5 | |
| 6 | - const TYPE_GET = 'GET'; |
|
| 7 | - const TYPE_SET = 'SET'; |
|
| 8 | - const TYPE_EXISTS = 'EXISTS'; |
|
| 9 | - const TYPE_UNSET = 'UNSET'; |
|
| 6 | + const TYPE_GET = 'GET'; |
|
| 7 | + const TYPE_SET = 'SET'; |
|
| 8 | + const TYPE_EXISTS = 'EXISTS'; |
|
| 9 | + const TYPE_UNSET = 'UNSET'; |
|
| 10 | 10 | |
| 11 | - private $logger; |
|
| 11 | + private $logger; |
|
| 12 | 12 | |
| 13 | - public function __construct() { |
|
| 13 | + public function __construct() { |
|
| 14 | 14 | |
| 15 | 15 | $this->logger = function($data_log) { |
| 16 | - return dump($data_log); |
|
| 16 | + return dump($data_log); |
|
| 17 | 17 | }; |
| 18 | 18 | |
| 19 | 19 | return call_user_func_array('parent::__construct', func_get_args()); |
| 20 | - } |
|
| 20 | + } |
|
| 21 | 21 | |
| 22 | - public function sendLog($type, $key, $value = null, array $backtrace ) { |
|
| 22 | + public function sendLog($type, $key, $value = null, array $backtrace ) { |
|
| 23 | 23 | |
| 24 | 24 | $logger = $this->logger; |
| 25 | 25 | $retorno['type'] = $type; |
@@ -28,33 +28,33 @@ discard block |
||
| 28 | 28 | $retorno['file'] = $backtrace[0]['file']; |
| 29 | 29 | $retorno['line'] = $backtrace[0]['line']; |
| 30 | 30 | return $logger($retorno); |
| 31 | - } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function setLogger(\Closure $logger) { |
|
| 33 | + public function setLogger(\Closure $logger) { |
|
| 34 | 34 | $this->logger = $logger; |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function offsetGet($name) { |
|
| 37 | + public function offsetGet($name) { |
|
| 38 | 38 | |
| 39 | 39 | $this->sendLog(static::TYPE_GET, $name, null, debug_backtrace()); |
| 40 | 40 | return call_user_func_array('parent::offsetGet', func_get_args()); |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function offsetSet($name, $value) { |
|
| 43 | + public function offsetSet($name, $value) { |
|
| 44 | 44 | |
| 45 | 45 | $this->sendLog(static::TYPE_SET, $name, $value, debug_backtrace()); |
| 46 | 46 | return call_user_func_array('parent::offsetSet', func_get_args()); |
| 47 | - } |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - public function offsetExists($name) { |
|
| 49 | + public function offsetExists($name) { |
|
| 50 | 50 | |
| 51 | 51 | $this->sendLog(static::TYPE_EXISTS, $name, null, debug_backtrace()); |
| 52 | 52 | return call_user_func_array('parent::offsetExists', func_get_args()); |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function offsetUnset($name) { |
|
| 55 | + public function offsetUnset($name) { |
|
| 56 | 56 | |
| 57 | 57 | $this->sendLog(static::TYPE_UNSET, $name, null, debug_backtrace()); |
| 58 | 58 | return call_user_func_array('parent::offsetUnset', func_get_args()); |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -10,8 +10,8 @@ |
||
| 10 | 10 | //\PHP\Utils::dump($sSql, $oObjeto); |
| 11 | 11 | |
| 12 | 12 | $test_array = array( |
| 13 | - "um" => 1, |
|
| 14 | - "dois" => 2 |
|
| 13 | + "um" => 1, |
|
| 14 | + "dois" => 2 |
|
| 15 | 15 | ); |
| 16 | 16 | |
| 17 | 17 | $test_array = new \PHP\ArrayDebugger($test_array); |
@@ -2,27 +2,27 @@ |
||
| 2 | 2 | namespace PHP; |
| 3 | 3 | use SqlFormatter; |
| 4 | 4 | /** |
| 5 | - * Utilitários para desenvolvimento |
|
| 6 | - * |
|
| 7 | - * @abstract |
|
| 8 | - */ |
|
| 5 | + * Utilitários para desenvolvimento |
|
| 6 | + * |
|
| 7 | + * @abstract |
|
| 8 | + */ |
|
| 9 | 9 | abstract class Utils { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Retorna o SQL Formatado e Destacado |
|
| 13 | - * |
|
| 14 | - * @param String $query |
|
| 15 | - */ |
|
| 16 | - public static function dump_sql($query) { |
|
| 11 | + /** |
|
| 12 | + * Retorna o SQL Formatado e Destacado |
|
| 13 | + * |
|
| 14 | + * @param String $query |
|
| 15 | + */ |
|
| 16 | + public static function dump_sql($query) { |
|
| 17 | 17 | echo SqlFormatter::format($query); |
| 18 | - } |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - public static function kill() { |
|
| 20 | + public static function kill() { |
|
| 21 | 21 | call_user_func_array("dump", func_get_args()); |
| 22 | 22 | die("\nFIM\n"); |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public static function dump() { |
|
| 25 | + public static function dump() { |
|
| 26 | 26 | return call_user_func_array("dump", func_get_args()); |
| 27 | - } |
|
| 27 | + } |
|
| 28 | 28 | } |