/**
  * Run the command. Executed immediately.
  *
  * @since 1.0.0
  *
  * @return int CLI tool exit code.
  */
 public function fire()
 {
     parent::fire();
     if ($this->option('install-ruleset')) {
         if ($this->installRuleset()) {
             $this->info('Copied ruleset to ' . $this->pathRulesetLocal);
         }
     }
     $this->info('Runing PHP Mess Detector...');
     $command = $this->pathCli . ' ';
     $command .= base_path() . '/' . $this->option('path') . ' ';
     $command .= 'text ';
     $command .= $this->pathRuleset;
     passthru($command, $exitCode);
     $this->info('Done.');
     return $exitCode;
 }
Beispiel #2
0
 /**
  * Get (or init) session counter(s).
  *
  * Counters will only be set and updated if conf var session_counters,
  * because this feature uses a cookie, and it also adds a slight performance
  * hit to each and every request.
  *
  *  Counters:
  *  - session: not a number, a custom session id (case-sensitive hex, approx.
  *    16 chars long), or simply 'na' (as in n/a)
  *  - page_load: number of request in session that produced 'page' (non-AJAX)
  *    output
  *  - request: number of requests in session
  *
  * @param string $name
  *   Default: empty (~ get all, as array).
  *   Values: session|page_load|request (~ get single value).
  *
  * @return mixed
  *   Array: all counters.
  *   String: session.
  *   Integer: page_load|request.
  *   NULL: bad arg $name.
  */
 public static function sessionCounters($name = '')
 {
     static $called;
     // Init first time called.
     if (!$called) {
         $called = TRUE;
         if (static::configGet('inspect', 'session_counters')) {
             if (($c = static::cookieGet('inspect__sc')) && preg_match('/^[a-zA-Z\\d]+\\:\\d{1,5}\\:\\d{1,5}$/', $c)) {
                 $c = explode(':', $c);
                 static::$sessionCounters = $counters = array('session' => $c[0], 'page_load' => $c[1], 'request' => (int) $c[2] + 1);
             } else {
                 $c = explode('.', uniqid('', TRUE));
                 static::$sessionCounters = $counters = array('session' => Inspect::baseConvert($c[0], 16, 62) . Inspect::baseConvert($c[1], 16, 62), 'page_load' => 0, 'request' => 1);
             }
             if (!headers_sent()) {
                 // Session counting is not important enough to risk PHP warning due
                 // to response body sending already commenced.
                 static::cookieSet('inspect__sc', join(':', static::$sessionCounters));
             }
         } else {
             $counters = static::$sessionCounters;
         }
     } else {
         $counters = static::$sessionCounters;
     }
     if ($name) {
         switch ('' . $name) {
             case 'session':
             case 'page_load':
             case 'request':
                 return $counters[$name];
         }
         return NULL;
     }
     return $counters;
 }
Beispiel #3
0
 /**
  * Force outputs any class property
  *
  * @param mixed       $variable name or value to be inspected
  * @param string|null $next     the name of the next available variable
  *
  * @return Eden\Core\Base
  */
 public function inspect($variable = null, $next = null)
 {
     //argument 2 must be a string or null
     Argument::i()->test(2, 'string', 'null');
     //we are using tool in all cases
     $class = get_class($this);
     //if variable is null
     if (is_null($variable)) {
         //output the class
         Inspect::i()->output(sprintf(Inspect::INSPECT, $class))->output($this);
         return $this;
     }
     //if variable is true
     if ($variable === true) {
         //return whatever the next response is
         //or return the next specified variable
         return Inspect::i()->next($this, $next);
     }
     //if variable is not a string
     if (!is_string($variable)) {
         //output variable
         Inspect::i()->output(sprintf(Inspect::INSPECT, 'Variable'))->output($variable);
         return $this;
     }
     //if variable is set
     if (isset($this->{$variable})) {
         //output it
         Inspect::i()->output(sprintf(Inspect::INSPECT, $class . '->' . $variable))->output($this->{$variable});
         return $this;
     }
     //any other case output variable
     Inspect::i()->output(sprintf(Inspect::INSPECT, 'Variable'))->output($variable);
     return $this;
 }