Skip to content

Commit 88b90af

Browse files
committed
Adds initial code to base debug class
1 parent e5eeee8 commit 88b90af

File tree

1 file changed

+139
-1
lines changed

1 file changed

+139
-1
lines changed

system/core/debug.php

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,145 @@
99
/**
1010
* The base Debug class
1111
*/
12-
class Convert
12+
class Debug
1313
{
14+
use Singleton;
1415

16+
/**
17+
* Prints a variable to the stdout.
18+
* @param mixed $var The variable to be printed to stdout.
19+
*/
20+
public static function p($var)
21+
{
22+
if (is_string($var) || is_numeric($var) || is_float($var) || is_long($var)) {
23+
echo $var;
24+
} elseif (is_array($var)){
25+
echo '<pre>' . print_r($var, true) . '</pre>';
26+
} elseif (is_bool($var)) {
27+
if ($var==true) { echo 'false'; } else { echo 'true'; }
28+
} elseif (is_object) {
29+
echo '<pre>' . print_r($var, true) . '</pre>';
30+
} else {
31+
echo $var;
32+
}
33+
}
34+
35+
/**
36+
* Prints the provided variables type to stdout.
37+
* @param mixed $checkVar The variable to have its type checked.
38+
*/
39+
public static function t($checkVar)
40+
{
41+
if (isset($checkVar)) {
42+
$varType = gettype($checkVar);
43+
echo '<br />Value type is: ' . $varType . '<br />';
44+
} else {
45+
return false;
46+
}
47+
}
48+
49+
/**
50+
* Prints detils about a supplied object to stdout.
51+
* @param object $object The object to have its details printed out to stdout.
52+
*/
53+
public static function o($object)
54+
{
55+
if (is_object($object)) {
56+
$this->classType($object);
57+
$this->classParent($object);
58+
$this->properties($object);
59+
$this->methods($object);
60+
} else {
61+
return false;
62+
}
63+
}
64+
65+
/**
66+
* Prints a list of currently active objects to stdout.
67+
*/
68+
public static function objList()
69+
{
70+
echo '<h2>Object List</h2>';
71+
$objArray = get_declared_classes();
72+
$this->p($objArray);
73+
}
74+
75+
/**
76+
* Prints a list of currently included files to stdout.
77+
*/
78+
public static function includeList()
79+
{
80+
echo '<h2>Include List</h2>';
81+
$includeArray = get_included_files();
82+
$this->p($includeArray);
83+
}
84+
85+
/**
86+
* Prints information about the current active objects and the included files to sdtout.
87+
*/
88+
public static function dump()
89+
{
90+
$this->objList();
91+
$this->includeList();
92+
}
93+
94+
/**
95+
* Prints detils about a supplied objects class to sdtout.
96+
* @param object $object The object to have its class type checked.
97+
*/
98+
public static function classType($object)
99+
{
100+
if (is_object($object)) {
101+
$classType = get_class($object);
102+
echo '<h2>Object Type</h2>';
103+
$this->p($classType);
104+
} else {
105+
return false;
106+
}
107+
}
108+
109+
/**
110+
* Prints detils about a supplied objects properties to sdtout.
111+
* @param object $object The object to have its properties checked.
112+
*/
113+
public static function properties($object)
114+
{
115+
if (is_object($object)) {
116+
$objArray = get_object_vars($object);
117+
echo '<h2>Object Properties</h2>';
118+
$this->p($objArray);
119+
} else {
120+
return false;
121+
}
122+
}
123+
124+
/**
125+
* Prints detils about a supplied objects methods to sdtout.
126+
* @param object $object The object to have its methods checked.
127+
*/
128+
public static function methods($object)
129+
{
130+
if (is_object($object)) {
131+
$objArray = get_class_methods($object);
132+
echo '<h2>Object Methods</h2>';
133+
$this->p($objArray);
134+
} else {
135+
return false;
136+
}
137+
}
138+
139+
/**
140+
* Prints detils about a supplied objects parent class to sdtout.
141+
* @param object $object The object to have its parent class checked.
142+
*/
143+
public static function classParent($object)
144+
{
145+
if (is_object($object)) {
146+
$parentClass = get_parent_class($object);
147+
echo '<h2>Object Parent</h2>';
148+
$this->p($parentClass);
149+
} else {
150+
return false;
151+
}
152+
}
15153
}

0 commit comments

Comments
 (0)