| @@ -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 | } | 
| @@ -10,9 +10,9 @@ | ||
| 10 | 10 |    private function __construct() { | 
| 11 | 11 | |
| 12 | 12 |      $this->oLogger = new \Monolog\Logger("PHPUtils"); | 
| 13 | -    $this->oLogger->pushHandler( new \Monolog\Handler\StreamHandler("/tmp/PHPUtils.log") ); | |
| 14 | - $this->oLogger->pushHandler( new \Monolog\Handler\ChromePHPHandler() ); | |
| 15 | - $this->oLogger->pushHandler( new \Monolog\Handler\FirePHPHandler() ); | |
| 13 | +    $this->oLogger->pushHandler(new \Monolog\Handler\StreamHandler("/tmp/PHPUtils.log")); | |
| 14 | + $this->oLogger->pushHandler(new \Monolog\Handler\ChromePHPHandler()); | |
| 15 | + $this->oLogger->pushHandler(new \Monolog\Handler\FirePHPHandler()); | |
| 16 | 16 | } | 
| 17 | 17 | |
| 18 | 18 |    public function log() {} | 
| @@ -19,7 +19,7 @@ | ||
| 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; | 
| @@ -3,31 +3,31 @@ 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 | - } | |
| 21 | - | |
| 22 | - /** | |
| 23 | - * Write log | |
| 24 | - * | |
| 25 | - * @param string $type | |
| 26 | - * @param string $key | |
| 27 | - * @param string $value | |
| 28 | - * @param array $backtrace | |
| 29 | - */ | |
| 30 | -  public function sendLog($type, $key, $value = null, array $backtrace ) { | |
| 20 | + } | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * Write log | |
| 24 | + * | |
| 25 | + * @param string $type | |
| 26 | + * @param string $key | |
| 27 | + * @param string $value | |
| 28 | + * @param array $backtrace | |
| 29 | + */ | |
| 30 | +    public function sendLog($type, $key, $value = null, array $backtrace ) { | |
| 31 | 31 | |
| 32 | 32 | $logger = $this->logger; | 
| 33 | 33 | $retorno['type'] = $type; | 
| @@ -36,59 +36,59 @@ discard block | ||
| 36 | 36 | $retorno['file'] = $backtrace[0]['file']; | 
| 37 | 37 | $retorno['line'] = $backtrace[0]['line']; | 
| 38 | 38 | return $logger($retorno); | 
| 39 | - } | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * Defines logger | |
| 43 | - * | |
| 44 | - * @param \Closure $logger | |
| 45 | - */ | |
| 46 | -  public function setLogger(\Closure $logger) { | |
| 39 | + } | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * Defines logger | |
| 43 | + * | |
| 44 | + * @param \Closure $logger | |
| 45 | + */ | |
| 46 | +    public function setLogger(\Closure $logger) { | |
| 47 | 47 | $this->logger = $logger; | 
| 48 | - } | |
| 48 | + } | |
| 49 | 49 | |
| 50 | - /** | |
| 51 | - * Called when getting a value from array | |
| 52 | - * | |
| 53 | - * @param mixed $name | |
| 54 | - */ | |
| 55 | -  public function offsetGet($name) {  | |
| 50 | + /** | |
| 51 | + * Called when getting a value from array | |
| 52 | + * | |
| 53 | + * @param mixed $name | |
| 54 | + */ | |
| 55 | +    public function offsetGet($name) {  | |
| 56 | 56 | |
| 57 | 57 | $this->sendLog(static::TYPE_GET, $name, null, debug_backtrace()); | 
| 58 | 58 |      return call_user_func_array('parent::offsetGet', func_get_args());  | 
| 59 | - } | |
| 59 | + } | |
| 60 | 60 | |
| 61 | - /** | |
| 62 | - * Called when setting a value from array | |
| 63 | - * | |
| 64 | - * @param mixed $name | |
| 65 | - * @param mixed $value | |
| 66 | - */ | |
| 67 | -  public function offsetSet($name, $value) {  | |
| 61 | + /** | |
| 62 | + * Called when setting a value from array | |
| 63 | + * | |
| 64 | + * @param mixed $name | |
| 65 | + * @param mixed $value | |
| 66 | + */ | |
| 67 | +    public function offsetSet($name, $value) {  | |
| 68 | 68 | |
| 69 | 69 | $this->sendLog(static::TYPE_SET, $name, $value, debug_backtrace()); | 
| 70 | 70 |      return call_user_func_array('parent::offsetSet', func_get_args());  | 
| 71 | - } | |
| 71 | + } | |
| 72 | 72 | |
| 73 | - /** | |
| 74 | - * Called when checking a value from array | |
| 75 | - * | |
| 76 | - * @param mixed $name | |
| 77 | - */ | |
| 78 | -  public function offsetExists($name) {  | |
| 73 | + /** | |
| 74 | + * Called when checking a value from array | |
| 75 | + * | |
| 76 | + * @param mixed $name | |
| 77 | + */ | |
| 78 | +    public function offsetExists($name) {  | |
| 79 | 79 | |
| 80 | 80 | $this->sendLog(static::TYPE_EXISTS, $name, null, debug_backtrace()); | 
| 81 | 81 |      return call_user_func_array('parent::offsetExists', func_get_args());  | 
| 82 | - } | |
| 82 | + } | |
| 83 | 83 | |
| 84 | - /** | |
| 85 | - * Called when removing a value from array | |
| 86 | - * | |
| 87 | - * @param mixed $name | |
| 88 | - */ | |
| 89 | -  public function offsetUnset($name) {  | |
| 84 | + /** | |
| 85 | + * Called when removing a value from array | |
| 86 | + * | |
| 87 | + * @param mixed $name | |
| 88 | + */ | |
| 89 | +    public function offsetUnset($name) {  | |
| 90 | 90 | |
| 91 | 91 | $this->sendLog(static::TYPE_UNSET, $name, null, debug_backtrace()); | 
| 92 | 92 |      return call_user_func_array('parent::offsetUnset', func_get_args());  | 
| 93 | - } | |
| 93 | + } | |
| 94 | 94 | } | 
| @@ -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 | } | 
| @@ -5,24 +5,24 @@ discard block | ||
| 5 | 5 | class ArrayDebuggerTest extends \PHPUnit_Framework_TestCase | 
| 6 | 6 |  { | 
| 7 | 7 | |
| 8 | - public $base = array( | |
| 8 | + public $base = array( | |
| 9 | 9 | 'hum' => 1, | 
| 10 | 10 | 'dois' => 2, | 
| 11 | 11 | 'tres' => 3 | 
| 12 | - ); | |
| 12 | + ); | |
| 13 | 13 | |
| 14 | -  public function testGetter() { | |
| 14 | +    public function testGetter() { | |
| 15 | 15 | |
| 16 | 16 | $array = new ArrayDebugger($this->base); | 
| 17 | 17 | |
| 18 | 18 |      $array->setLogger(function($retorno)  { | 
| 19 | - $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_GET); | |
| 19 | + $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_GET); | |
| 20 | 20 | }); | 
| 21 | 21 | |
| 22 | 22 | $teste = $array['hum']; | 
| 23 | 23 | |
| 24 | 24 |      $array->setLogger(function($retorno) { | 
| 25 | - $this->assertNotEquals($retorno['type'], ArrayDebugger::TYPE_GET); | |
| 25 | + $this->assertNotEquals($retorno['type'], ArrayDebugger::TYPE_GET); | |
| 26 | 26 | }); | 
| 27 | 27 | |
| 28 | 28 | $array['quatro'] = 4; | 
| @@ -35,20 +35,20 @@ discard block | ||
| 35 | 35 | * offsetUnset | 
| 36 | 36 | */ | 
| 37 | 37 | unset($array['quatro']); | 
| 38 | - } | |
| 38 | + } | |
| 39 | 39 | |
| 40 | -  public function testSetter() { | |
| 40 | +    public function testSetter() { | |
| 41 | 41 | |
| 42 | 42 | $array = new ArrayDebugger($this->base); | 
| 43 | 43 | |
| 44 | 44 |      $array->setLogger(function($retorno)  { | 
| 45 | - $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_SET); | |
| 45 | + $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_SET); | |
| 46 | 46 | }); | 
| 47 | 47 | |
| 48 | 48 | $array['quatro'] = 4; | 
| 49 | 49 | |
| 50 | 50 |      $array->setLogger(function($retorno) { | 
| 51 | - $this->assertNotEquals($retorno['type'], ArrayDebugger::TYPE_SET); | |
| 51 | + $this->assertNotEquals($retorno['type'], ArrayDebugger::TYPE_SET); | |
| 52 | 52 | }); | 
| 53 | 53 | |
| 54 | 54 | $teste = $array['hum']; | 
| @@ -61,14 +61,14 @@ discard block | ||
| 61 | 61 | * offsetUnset | 
| 62 | 62 | */ | 
| 63 | 63 | unset($array['quatro']); | 
| 64 | - } | |
| 64 | + } | |
| 65 | 65 | |
| 66 | -  public function testIsset() { | |
| 66 | +    public function testIsset() { | |
| 67 | 67 | |
| 68 | 68 | $array = new ArrayDebugger($this->base); | 
| 69 | 69 | |
| 70 | 70 |      $array->setLogger(function($retorno)  { | 
| 71 | - $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_EXISTS); | |
| 71 | + $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_EXISTS); | |
| 72 | 72 | }); | 
| 73 | 73 | |
| 74 | 74 | |
| @@ -78,7 +78,7 @@ discard block | ||
| 78 | 78 | isset($array['hum']); | 
| 79 | 79 | |
| 80 | 80 |      $array->setLogger(function($retorno) { | 
| 81 | - $this->assertNotEquals($retorno['type'], ArrayDebugger::TYPE_EXISTS); | |
| 81 | + $this->assertNotEquals($retorno['type'], ArrayDebugger::TYPE_EXISTS); | |
| 82 | 82 | }); | 
| 83 | 83 | |
| 84 | 84 | $array['quatro'] = 4; | 
| @@ -89,14 +89,14 @@ discard block | ||
| 89 | 89 | * offsetUnset | 
| 90 | 90 | */ | 
| 91 | 91 | unset($array['quatro']); | 
| 92 | - } | |
| 92 | + } | |
| 93 | 93 | |
| 94 | -  public function testUnset() { | |
| 94 | +    public function testUnset() { | |
| 95 | 95 | |
| 96 | 96 | $array = new ArrayDebugger($this->base); | 
| 97 | 97 | |
| 98 | 98 |      $array->setLogger(function($retorno)  { | 
| 99 | - $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_UNSET); | |
| 99 | + $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_UNSET); | |
| 100 | 100 | }); | 
| 101 | 101 | |
| 102 | 102 | /** | 
| @@ -105,7 +105,7 @@ discard block | ||
| 105 | 105 | unset($array['dois']); | 
| 106 | 106 | |
| 107 | 107 |      $array->setLogger(function($retorno) { | 
| 108 | - $this->assertNotEquals($retorno['type'], ArrayDebugger::TYPE_UNSET); | |
| 108 | + $this->assertNotEquals($retorno['type'], ArrayDebugger::TYPE_UNSET); | |
| 109 | 109 | }); | 
| 110 | 110 | /** | 
| 111 | 111 | * offsetExists | 
| @@ -116,5 +116,5 @@ discard block | ||
| 116 | 116 | |
| 117 | 117 | $teste = $array['hum']; | 
| 118 | 118 | |
| 119 | - } | |
| 119 | + } | |
| 120 | 120 | } | 
| @@ -15,7 +15,7 @@ discard block | ||
| 15 | 15 | |
| 16 | 16 | $array = new ArrayDebugger($this->base); | 
| 17 | 17 | |
| 18 | -    $array->setLogger(function($retorno)  { | |
| 18 | +    $array->setLogger(function($retorno) { | |
| 19 | 19 | $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_GET); | 
| 20 | 20 | }); | 
| 21 | 21 | |
| @@ -41,7 +41,7 @@ discard block | ||
| 41 | 41 | |
| 42 | 42 | $array = new ArrayDebugger($this->base); | 
| 43 | 43 | |
| 44 | -    $array->setLogger(function($retorno)  { | |
| 44 | +    $array->setLogger(function($retorno) { | |
| 45 | 45 | $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_SET); | 
| 46 | 46 | }); | 
| 47 | 47 | |
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 | |
| 68 | 68 | $array = new ArrayDebugger($this->base); | 
| 69 | 69 | |
| 70 | -    $array->setLogger(function($retorno)  { | |
| 70 | +    $array->setLogger(function($retorno) { | |
| 71 | 71 | $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_EXISTS); | 
| 72 | 72 | }); | 
| 73 | 73 | |
| @@ -95,7 +95,7 @@ discard block | ||
| 95 | 95 | |
| 96 | 96 | $array = new ArrayDebugger($this->base); | 
| 97 | 97 | |
| 98 | -    $array->setLogger(function($retorno)  { | |
| 98 | +    $array->setLogger(function($retorno) { | |
| 99 | 99 | $this->assertEquals($retorno['type'], ArrayDebugger::TYPE_UNSET); | 
| 100 | 100 | }); | 
| 101 | 101 | |
| @@ -1,19 +1,19 @@ | ||
| 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 | } | 
| 16 | 16 | |
| 17 | 17 |  function debug_array(&$array) { | 
| 18 | - return new \PHP\ArrayDebugger($array); | |
| 18 | + return new \PHP\ArrayDebugger($array); | |
| 19 | 19 | } |