add shipping rules
This commit is contained in:
@@ -2,15 +2,16 @@
|
||||
|
||||
namespace App\Repositories\Core;
|
||||
|
||||
use \League\CLImate\CLImate;
|
||||
use \Timer;
|
||||
use League\CLImate\CLImate;
|
||||
use Timer;
|
||||
|
||||
class Debug
|
||||
{
|
||||
|
||||
// $is_debug binaire 0 ou 1 debug, 0 ou 1 force output
|
||||
public static $_instance;
|
||||
|
||||
public static $app;
|
||||
|
||||
public static $debugbar;
|
||||
|
||||
private function __construct()
|
||||
@@ -28,9 +29,9 @@ class Debug
|
||||
return class_exists('Clockwork\Support\Laravel\ClockworkServiceProvider') ? true : false;
|
||||
}
|
||||
|
||||
public static function start($var = '', $params = array(), $txt = '')
|
||||
public static function start($var = '', $params = [], $txt = '')
|
||||
{
|
||||
if (!static::isDebug()) {
|
||||
if (! static::isDebug()) {
|
||||
return false;
|
||||
}
|
||||
$var = (empty($var)) ? static::getMethod() : $var;
|
||||
@@ -42,7 +43,7 @@ class Debug
|
||||
*/
|
||||
// TODO Fixer la longueur des params string passés
|
||||
if (is_null($params)) {
|
||||
$params = array();
|
||||
$params = [];
|
||||
}
|
||||
|
||||
Timer::start($var, $params);
|
||||
@@ -58,7 +59,7 @@ class Debug
|
||||
|
||||
public static function stop($var = '')
|
||||
{
|
||||
if (!static::isDebug()) {
|
||||
if (! static::isDebug()) {
|
||||
return false;
|
||||
}
|
||||
$var = (empty($var)) ? static::getMethod() : $var;
|
||||
@@ -97,7 +98,7 @@ class Debug
|
||||
/**
|
||||
* dump un message uniquement si debug est true
|
||||
*
|
||||
* @param string $msg [description]
|
||||
* @param string $msg [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function message($msg, $cat = '')
|
||||
@@ -110,7 +111,7 @@ class Debug
|
||||
/**
|
||||
* force la sortie d'un dump, sans passer par la debugbar ou test si debug est true
|
||||
*
|
||||
* @param string $msg [description]
|
||||
* @param string $msg [description]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function fdump($msg, $cat = '')
|
||||
@@ -122,7 +123,7 @@ class Debug
|
||||
* dump un message suivant le handler de sortie prévu (log, debugbar, cli, ...)
|
||||
*
|
||||
* @param [type] $msg [description]
|
||||
* @param boolean $force si true, force la sortie en output direct
|
||||
* @param bool $force si true, force la sortie en output direct
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public static function dump($msg, $cat = '', $force = false)
|
||||
@@ -133,18 +134,19 @@ class Debug
|
||||
dump($msg);
|
||||
}
|
||||
|
||||
if (!self::isDebug()){
|
||||
return;}
|
||||
if (static::isCLI()) {
|
||||
self::dumpCli($msg, $cat);
|
||||
}
|
||||
if (static::isDebugbar()) {
|
||||
self::dumpDebugbar($msg, $cat);
|
||||
}
|
||||
if (static::isClockwork()) {
|
||||
self::dumpClockwork($msg, $cat);
|
||||
}
|
||||
|
||||
if (! self::isDebug()) {
|
||||
return;
|
||||
}
|
||||
if (static::isCLI()) {
|
||||
self::dumpCli($msg, $cat);
|
||||
}
|
||||
if (static::isDebugbar()) {
|
||||
self::dumpDebugbar($msg, $cat);
|
||||
}
|
||||
if (static::isClockwork()) {
|
||||
self::dumpClockwork($msg, $cat);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function dumpDebugbar($msg, $cat = '', $force = false)
|
||||
@@ -199,10 +201,11 @@ class Debug
|
||||
$is_debug = false;
|
||||
}
|
||||
} else {
|
||||
dump("la isDebug::165");
|
||||
dump('la isDebug::165');
|
||||
dump($caller);
|
||||
$is_debug = true;
|
||||
}
|
||||
|
||||
return $is_debug;
|
||||
}
|
||||
|
||||
@@ -212,8 +215,8 @@ class Debug
|
||||
$backtrace = debug_backtrace();
|
||||
$backtrace = array_reverse($backtrace);
|
||||
foreach ($backtrace as $item) {
|
||||
$caller = isset($item['class']) ? $item['class'] . $item['type'] . $item['function'] : $item['function'];
|
||||
$place = isset($item['file']) ? $item['file'] . ' at ' . $item['line'] : '';
|
||||
$caller = isset($item['class']) ? $item['class'].$item['type'].$item['function'] : $item['function'];
|
||||
$place = isset($item['file']) ? $item['file'].' at '.$item['line'] : '';
|
||||
$txt .= "$caller | $place \n";
|
||||
}
|
||||
static::dump($txt, '', $force);
|
||||
@@ -222,12 +225,12 @@ class Debug
|
||||
|
||||
public static function getLocation()
|
||||
{
|
||||
return static::getMethod() . ' at ' . static::getFile() . ' line ' . static::getLine();
|
||||
return static::getMethod().' at '.static::getFile().' line '.static::getLine();
|
||||
}
|
||||
|
||||
public static function getMethod()
|
||||
{
|
||||
return (static::getClass() . static::getType() . static::getFunction());
|
||||
return static::getClass().static::getType().static::getFunction();
|
||||
}
|
||||
|
||||
public static function getClass()
|
||||
@@ -269,6 +272,7 @@ class Debug
|
||||
while ($backtrace[$k]['class'] == 'App\Repositories\Core\Debug') {
|
||||
$k++;
|
||||
}
|
||||
|
||||
return (object) $backtrace[$k];
|
||||
}
|
||||
|
||||
@@ -280,6 +284,7 @@ class Debug
|
||||
while ($backtrace[$k]['class'] == 'App\Repositories\Core\Debug') {
|
||||
$k++;
|
||||
}
|
||||
|
||||
return (object) $backtrace[$k - 1];
|
||||
}
|
||||
|
||||
@@ -288,14 +293,15 @@ class Debug
|
||||
$backtrace = debug_backtrace();
|
||||
$object = isset($backtrace[0]['object']) ? $backtrace[0]['object'] : null;
|
||||
$k = 1;
|
||||
while (isset($backtrace[$k]) && (!isset($backtrace[$k]['object']) || $object === $backtrace[$k]['object'])) {
|
||||
while (isset($backtrace[$k]) && (! isset($backtrace[$k]['object']) || $object === $backtrace[$k]['object'])) {
|
||||
$k++;
|
||||
}
|
||||
|
||||
return isset($backtrace[$k]['object']) ? $backtrace[$k]['object'] : null;
|
||||
}
|
||||
|
||||
public static function isCLI()
|
||||
{
|
||||
return (PHP_SAPI == 'cli');
|
||||
return PHP_SAPI == 'cli';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user