Helix Installation   Getting Started   Reference Documentation   Global Functions   Quick Start
ModulesClassesFunctions
 

Class Reference

class debugger extends obj

Hide Inherited MembersHelix Core
Description
No description.
 
Constants
No constants.
 
Properties
protected_basename[ debugger ]
protected_bytes[ debugger ]
protected_dirname[ debugger ]
protected_dirty[ obj ]
protected_enabled[ debugger ]
protected_extension[ debugger ]
protected_filename[ debugger ]
protected_mdate[ debugger ]
protected_path[ debugger ]
protected_path_parts[ debugger ]
protected_prefix[ debugger ]
publicproperty_objects_array[ obj ]
protected_today[ debugger ]
 
Methods
protectedarchive ( )[ debugger ]
Parameters
No parameters for this method
Code
045  protected function archive()
046  {
047      $count = count(glob("{$this->dirname}/{$this->prefix}*"));
048      $archive_path = "{$this->dirname}/{$this->prefix}." . lpad($count+1,2,0) . ".{$this->extension}";
049      return rename($this->path,$archive_path);
050  }
public__construct ( error_log )[ debugger ]
Parameters
optionalerror_log
Code
016  public function __construct($__error_log=null)
017  {
018      $this->enabled = is_true(DEBUG);
019      $this->path = is_null($__error_log) ? ini_get("error_log") : $__error_log;
020      $this->path_parts = pathinfo($this->path);
021      $this->dirname = $this->path_parts["dirname"];
022      $this->filename = $this->path_parts["filename"];
023      $this->basename = $this->path_parts["basename"];
024      $this->extension = $this->path_parts["extension"];
025      $this->today = date("Ymd");
026      $this->mdate = file_exists($this->path) ? date("Ymd",filemtime($this->path)) : $this->today;
027      $this->prefix = "{$this->filename}.{$this->mdate}";
028      $this->bytes = file_exists($this->path) ? strlen(file_get_contents($this->path)) : 0;
029  }
public__get ( p )[ obj ]
Parameters
requiredp
Code
007  public function __get($p)
008  {
009      $methods = get_class_methods($this);
010      $properties = get_object_vars($this);
011      if (in_array("get_$p",$methods))
012      {
013          return $this->{"get_$p"}();
014      }
015      else if (array_key_exists("_$p",$properties))
016      {
017          return $this->{"_$p"};
018      }
019      else if (in_array("get_" . substr($p,strpos($p,"_")+1), $methods))
020      {
021          return $this->{"get_" . substr($p,strpos($p,"_")+1)}(substr($p,0,strpos($p,"_")));
022      }
023      else
024      {
025          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
026          return null;
027      }
028  }
publicget_array ( )[ obj ]
Parameters
No parameters for this method
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicget_classname ( )[ obj ]
Parameters
No parameters for this method
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicget_dirty ( )[ obj ]
Parameters
No parameters for this method
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicget_json ( )[ obj ]
Parameters
No parameters for this method
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicget_properties ( )[ obj ]
Parameters
No parameters for this method
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
protectedget_string ( )[ obj ]
Parameters
No parameters for this method
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
publiclog ( message , file , line )[ debugger ]
Parameters
optionalmessage
optionalfile
optionalline
Code
052  public function log($__message=null, $__file=null, $__line=null)
053  {
054      global $sess;
055      if ($this->enabled)
056      {
057          $text = "[" . date("d-M-Y H:i:s") . "] [" . lpad($sess->id,5) . "] $__message\n";
058          $newsize = $this->bytes + strlen($text);
059          if ($this->mdate == $this->today)
060          {
061              if ($newsize > 1024*LOG_MAX_SIZE)
062              {
063                  $this->archive();
064              }
065          }
066          else
067          {
068              $this->archive();
069          }
070          $this->write($text);
071      }
072  }
public__set ( p , v )[ obj ]
Parameters
requiredp
requiredv
Code
030  public function __set($p,$v)
031  {
032      $methods = get_class_methods($this);
033      $properties = get_object_vars($this);
034      if (in_array("set_$p",$methods))
035      {
036          $this->{"set_$p"}($v);
037      }
038      else if (array_key_exists("_$p",$properties))
039      {
040          if (!preg_match('/_dirty$/',$p) && property_exists($this,"_{$p}_dirty"))
041          {
042              if (is_object($this->{"_$p"}))
043              {
044                  $this->{"_$p"}->dirty = true;
045              }
046              else
047              {
048                  $this->{"_{$p}_dirty"} = $this->{$p}==$v ? false : true;
049              }
050          }
051          $this->{"_$p"} = $v;
052      }
053      else if (in_array("set_" . substr($p,strpos($p,"_")+1), $methods))
054      {
055          $this->{"set_" . substr($p,strpos($p,"_")+1)}($v,substr($p,0,strpos($p,"_")));
056      }
057      else
058      {
059          trigger_error("This object [" . get_class($this) . ":$this->id] has no private property '_$p' for the requested public property '$p'",E_USER_WARNING);
060      }
061  }
protectedwrite ( text )[ debugger ]
Parameters
optionaltext
Code
031  protected function write($__text=null)
032  {
033      $fo = fopen($this->path,'a');
034      $bytes_written = fwrite($fo,$__text);
035      fclose($fo);
036      $this->bytes = file_exists($this->path) ? strlen(file_get_contents($this->path)) : 0;
037      if ($bytes_written === false)
038      {
039          trigger_error("CANNOT WRITE TO {$this->path}",E_USER_WARNING);
040      }
041      $this->mdate = $this->today;
042      return $bytes_written;
043  }
 
Accessors
publicarray[ obj ]
Code
096  public function get_array()
097  {
098      return get_object_vars($this);
099  }
publicclassname[ obj ]
Code
086  public function get_classname()
087  {
088      return get_class($this);
089  }
publicdirty[ obj ]
Code
063  public function get_dirty()
064  {
065      if ($this->id === 0)
066      {
067          $this->_dirty = true;
068      }
069      else
070      {
071          foreach (get_object_vars($this) as $k=>$v)
072          {
073              if ($this->_dirty)
074              {
075                  break;
076              }
077              if (preg_match('/_dirty$/',$k))
078              {
079                  $this->_dirty = $this->_dirty || $v;
080              }
081          }
082      }
083      return $this->_dirty;
084  }
publicjson[ obj ]
Code
101  public function get_json()
102  {
103      $class = new ReflectionClass($this->classname);
104      $methods = $class->getMethods();
105      usort($methods,"sort_reflection_objects");
106      $accessors = array();
107      foreach ($methods as $index=>$method)
108      {
109          $declarer = $method->getDeclaringClass()->name;
110          if (preg_match('/^(get|set|)_(.+)$/',$method->name,$matches))
111          {
112              $accessor = $matches[2];
113              $getset = $matches[1];
114              eval("\$accessors[\$accessor] = \$this->".$accessor.";");
115          }
116      }
117      //return json_encode($this->get_array());
118      return json_encode($accessors);
119  }
publicproperties[ obj ]
Code
121  public function get_properties()
122  {
123      return array_keys($this->array);
124  }
publicstring[ obj ]
Code
091  protected function get_string()
092  {
093      return method_exists($this,"__toString") ? $this->__toString() : null;
094  }
Get Helix PHP Framework at SourceForge.net. Fast, secure and Free Open Source software downloads