Completed
Push — master ( c6e8cc...5bd743 )
by Jacob
02:18
created
src/Console.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -15,88 +15,88 @@
 block discarded – undo
15 15
 class Console
16 16
 {
17 17
 
18
-    /** @var  array */
19
-    protected $store = array();
18
+	/** @var  array */
19
+	protected $store = array();
20 20
 
21
-    /**
22
-     * Logs data to the console
23
-     * Accepts any data type
24
-     *
25
-     * @param mixed $data
26
-     */
27
-    public function log($data)
28
-    {
29
-        array_push($this->store, array(
30
-          'data' => $data,
31
-          'type' => 'log'
32
-        ));
33
-    }
21
+	/**
22
+	 * Logs data to the console
23
+	 * Accepts any data type
24
+	 *
25
+	 * @param mixed $data
26
+	 */
27
+	public function log($data)
28
+	{
29
+		array_push($this->store, array(
30
+		  'data' => $data,
31
+		  'type' => 'log'
32
+		));
33
+	}
34 34
 
35
-    /**
36
-     * Logs memory usage of a variable
37
-     * If no parameter is passed in, logs current memory usage
38
-     *
39
-     * @param mixed $object
40
-     * @param string $name
41
-     */
42
-    public function logMemory($object = null, $name = 'PHP')
43
-    {
44
-        $memory = memory_get_usage();
45
-        $dataType = '';
46
-        if (!is_null($object)) {
47
-            $memory = strlen(serialize($object));
48
-            $dataType = gettype($object);
49
-        }
35
+	/**
36
+	 * Logs memory usage of a variable
37
+	 * If no parameter is passed in, logs current memory usage
38
+	 *
39
+	 * @param mixed $object
40
+	 * @param string $name
41
+	 */
42
+	public function logMemory($object = null, $name = 'PHP')
43
+	{
44
+		$memory = memory_get_usage();
45
+		$dataType = '';
46
+		if (!is_null($object)) {
47
+			$memory = strlen(serialize($object));
48
+			$dataType = gettype($object);
49
+		}
50 50
 
51
-        array_push($this->store, array(
52
-            'name'      => $name,
53
-            'data'      => $memory,
54
-            'data_type' => $dataType,
55
-            'type'      => 'memory'
56
-        ));
57
-    }
51
+		array_push($this->store, array(
52
+			'name'      => $name,
53
+			'data'      => $memory,
54
+			'data_type' => $dataType,
55
+			'type'      => 'memory'
56
+		));
57
+	}
58 58
 
59
-    /**
60
-     * Logs exception with optional message override
61
-     *
62
-     * @param Exception $exception
63
-     * @param string    $message
64
-     */
65
-    public function logError(Exception $exception, $message = '')
66
-    {
67
-        if (empty($message)) {
68
-            $message = $exception->getMessage();
69
-        }
59
+	/**
60
+	 * Logs exception with optional message override
61
+	 *
62
+	 * @param Exception $exception
63
+	 * @param string    $message
64
+	 */
65
+	public function logError(Exception $exception, $message = '')
66
+	{
67
+		if (empty($message)) {
68
+			$message = $exception->getMessage();
69
+		}
70 70
 
71
-        array_push($this->store, array(
72
-            'data' => $message,
73
-            'file' => $exception->getFile(),
74
-            'line' => $exception->getLine(),
75
-            'type' => 'error'
76
-        ));
77
-    }
71
+		array_push($this->store, array(
72
+			'data' => $message,
73
+			'file' => $exception->getFile(),
74
+			'line' => $exception->getLine(),
75
+			'type' => 'error'
76
+		));
77
+	}
78 78
 
79
-    /**
80
-     * Logs current time with optional message
81
-     *
82
-     * @param string $name
83
-     */
84
-    public function logSpeed($name = 'Point in Time')
85
-    {
86
-        array_push($this->store, array(
87
-            'data' => microtime(true),
88
-            'name' => $name,
89
-            'type' => 'speed'
90
-        ));
91
-    }
79
+	/**
80
+	 * Logs current time with optional message
81
+	 *
82
+	 * @param string $name
83
+	 */
84
+	public function logSpeed($name = 'Point in Time')
85
+	{
86
+		array_push($this->store, array(
87
+			'data' => microtime(true),
88
+			'name' => $name,
89
+			'type' => 'speed'
90
+		));
91
+	}
92 92
 
93
-    /**
94
-     * Returns the collected logs
95
-     *
96
-     * @returns array
97
-     */
98
-    public function getLogs()
99
-    {
100
-        return $this->store;
101
-    }
93
+	/**
94
+	 * Returns the collected logs
95
+	 *
96
+	 * @returns array
97
+	 */
98
+	public function getLogs()
99
+	{
100
+		return $this->store;
101
+	}
102 102
 }
Please login to merge, or discard this patch.
tests/unit/ConsoleTest.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -9,108 +9,108 @@
 block discarded – undo
9 9
 class ConsoleTest extends PHPUnit_Framework_TestCase
10 10
 {
11 11
 
12
-    public function testLog()
13
-    {
14
-        $data = array(
15
-            'key' => 'value'
16
-        );
17
-
18
-        $console = new Console();
19
-        $console->log($data);
20
-        $store = $this->getProtectedStore($console);
21
-        $log = array_pop($store);
22
-
23
-        $this->assertSame($data, $log['data']);
24
-        $this->assertEquals('log', $log['type']);
25
-    }
26
-
27
-    public function testLogMemory()
28
-    {
29
-        $data = array(
30
-            'key' => 'value'
31
-        );
32
-        $memory = strlen(serialize($data));
33
-        $name = 'Test Array';
34
-
35
-        $console = new Console();
36
-        $console->logMemory($data, $name);
37
-        $store = $this->getProtectedStore($console);
38
-        $log = array_pop($store);
39
-
40
-        $this->assertEquals($name, $log['name']);
41
-        $this->assertEquals($memory, $log['data']);
42
-        $this->assertEquals('array', $log['data_type']);
43
-        $this->assertEquals('memory', $log['type']);
44
-    }
45
-
46
-    public function testLogError()
47
-    {
48
-        $error = new Exception('Test Exception');
49
-
50
-        $console = new Console();
51
-        $console->logError($error);
52
-        $store = $this->getProtectedStore($console);
53
-        $log = array_pop($store);
54
-
55
-        $this->assertEquals($error->getMessage(), $log['data']);
56
-        $this->assertEquals($error->getFile(), $log['file']);
57
-        $this->assertEquals($error->getLine(), $log['line']);
58
-        $this->assertEquals('error', $log['type']);
59
-
60
-        $error = new Exception('Test Exception');
61
-        $message = 'override message';
62
-
63
-        $console = new Console();
64
-        $console->logError($error, $message);
65
-        $store = $this->getProtectedStore($console);
66
-        $log = array_pop($store);
67
-
68
-        $this->assertEquals($message, $log['data']);
69
-    }
70
-
71
-    public function testLogSpeed()
72
-    {
73
-        $name = 'Test Speed';
74
-
75
-        $console = new Console();
76
-        $console->logSpeed($name);
77
-        $store = $this->getProtectedStore($console);
78
-        $log = array_pop($store);
79
-
80
-        $this->assertEquals($name, $log['name']);
81
-        $this->assertEquals('speed', $log['type']);
82
-    }
83
-
84
-    public function testGetLogs()
85
-    {
86
-        $store = array(
87
-            array(
88
-                'data' => 'a string',
89
-                'type' => 'log'
90
-            ),
91
-            array(
92
-                'name' => '',
93
-                'data' => 123,
94
-                'data_type' => 'array',
95
-                'type' => 'memory'
96
-            )
97
-        );
98
-
99
-        $console = new Console();
100
-
101
-        $reflectedConsole = new ReflectionClass(get_class($console));
102
-        $reflectedProperty = $reflectedConsole->getProperty('store');
103
-        $reflectedProperty->setAccessible(true);
104
-        $reflectedProperty->setValue($console, $store);
105
-
106
-        $this->assertSame($store, $console->getLogs());
107
-    }
108
-
109
-    protected function getProtectedStore(Console $console)
110
-    {
111
-        $reflectedConsole = new ReflectionClass(get_class($console));
112
-        $reflectedProperty = $reflectedConsole->getProperty('store');
113
-        $reflectedProperty->setAccessible(true);
114
-        return $reflectedProperty->getValue($console);
115
-    }
12
+	public function testLog()
13
+	{
14
+		$data = array(
15
+			'key' => 'value'
16
+		);
17
+
18
+		$console = new Console();
19
+		$console->log($data);
20
+		$store = $this->getProtectedStore($console);
21
+		$log = array_pop($store);
22
+
23
+		$this->assertSame($data, $log['data']);
24
+		$this->assertEquals('log', $log['type']);
25
+	}
26
+
27
+	public function testLogMemory()
28
+	{
29
+		$data = array(
30
+			'key' => 'value'
31
+		);
32
+		$memory = strlen(serialize($data));
33
+		$name = 'Test Array';
34
+
35
+		$console = new Console();
36
+		$console->logMemory($data, $name);
37
+		$store = $this->getProtectedStore($console);
38
+		$log = array_pop($store);
39
+
40
+		$this->assertEquals($name, $log['name']);
41
+		$this->assertEquals($memory, $log['data']);
42
+		$this->assertEquals('array', $log['data_type']);
43
+		$this->assertEquals('memory', $log['type']);
44
+	}
45
+
46
+	public function testLogError()
47
+	{
48
+		$error = new Exception('Test Exception');
49
+
50
+		$console = new Console();
51
+		$console->logError($error);
52
+		$store = $this->getProtectedStore($console);
53
+		$log = array_pop($store);
54
+
55
+		$this->assertEquals($error->getMessage(), $log['data']);
56
+		$this->assertEquals($error->getFile(), $log['file']);
57
+		$this->assertEquals($error->getLine(), $log['line']);
58
+		$this->assertEquals('error', $log['type']);
59
+
60
+		$error = new Exception('Test Exception');
61
+		$message = 'override message';
62
+
63
+		$console = new Console();
64
+		$console->logError($error, $message);
65
+		$store = $this->getProtectedStore($console);
66
+		$log = array_pop($store);
67
+
68
+		$this->assertEquals($message, $log['data']);
69
+	}
70
+
71
+	public function testLogSpeed()
72
+	{
73
+		$name = 'Test Speed';
74
+
75
+		$console = new Console();
76
+		$console->logSpeed($name);
77
+		$store = $this->getProtectedStore($console);
78
+		$log = array_pop($store);
79
+
80
+		$this->assertEquals($name, $log['name']);
81
+		$this->assertEquals('speed', $log['type']);
82
+	}
83
+
84
+	public function testGetLogs()
85
+	{
86
+		$store = array(
87
+			array(
88
+				'data' => 'a string',
89
+				'type' => 'log'
90
+			),
91
+			array(
92
+				'name' => '',
93
+				'data' => 123,
94
+				'data_type' => 'array',
95
+				'type' => 'memory'
96
+			)
97
+		);
98
+
99
+		$console = new Console();
100
+
101
+		$reflectedConsole = new ReflectionClass(get_class($console));
102
+		$reflectedProperty = $reflectedConsole->getProperty('store');
103
+		$reflectedProperty->setAccessible(true);
104
+		$reflectedProperty->setValue($console, $store);
105
+
106
+		$this->assertSame($store, $console->getLogs());
107
+	}
108
+
109
+	protected function getProtectedStore(Console $console)
110
+	{
111
+		$reflectedConsole = new ReflectionClass(get_class($console));
112
+		$reflectedProperty = $reflectedConsole->getProperty('store');
113
+		$reflectedProperty->setAccessible(true);
114
+		return $reflectedProperty->getValue($console);
115
+	}
116 116
 }
Please login to merge, or discard this patch.
tests/helpers/function-overrides.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -5,37 +5,37 @@
 block discarded – undo
5 5
 // namespace hack on microtime functionality
6 6
 function microtime()
7 7
 {
8
-    return 1450355136.5706;
8
+	return 1450355136.5706;
9 9
 }
10 10
 
11 11
 // namespace hack on included files functionality
12 12
 function get_included_files()
13 13
 {
14
-    return array(
15
-        'index.php',
16
-        'src/Class.php'
17
-    );
14
+	return array(
15
+		'index.php',
16
+		'src/Class.php'
17
+	);
18 18
 }
19 19
 
20 20
 // namespace hack on filesize
21 21
 function filesize($filename)
22 22
 {
23
-    return strlen($filename) * 100;
23
+	return strlen($filename) * 100;
24 24
 }
25 25
 
26 26
 // namespace hack on memory usage
27 27
 function memory_get_peak_usage()
28 28
 {
29
-    return 123456789;
29
+	return 123456789;
30 30
 }
31 31
 
32 32
 // namespace hack on ini settings
33 33
 function ini_get($setting)
34 34
 {
35
-    if ($setting == 'memory_limit') {
36
-        return '128M';
37
-    } elseif ($setting == 'max_execution_time') {
38
-        return '30';
39
-    }
40
-    return \ini_get($setting);
35
+	if ($setting == 'memory_limit') {
36
+		return '128M';
37
+	} elseif ($setting == 'max_execution_time') {
38
+		return '30';
39
+	}
40
+	return \ini_get($setting);
41 41
 }
Please login to merge, or discard this patch.
tests/helpers/LoggingPdo.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,5 +6,5 @@
 block discarded – undo
6 6
 
7 7
 class LoggingPdo extends PDO
8 8
 {
9
-    public $queries = array();
9
+	public $queries = array();
10 10
 }
Please login to merge, or discard this patch.
tests/unit/PhpQuickProfilerTest.php 1 patch
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -9,19 +9,19 @@  discard block
 block discarded – undo
9 9
 class PhpQuickProfilerTest extends PHPUnit_Framework_TestCase
10 10
 {
11 11
 
12
-    protected static $dbConnection;
12
+	protected static $dbConnection;
13 13
 
14
-    public static function setUpBeforeClass()
15
-    {
16
-        self::$dbConnection = new LoggingPdo('sqlite::memory:');
17
-        $createTable = "
14
+	public static function setUpBeforeClass()
15
+	{
16
+		self::$dbConnection = new LoggingPdo('sqlite::memory:');
17
+		$createTable = "
18 18
             CREATE TABLE IF NOT EXISTS `testing` (
19 19
                 `id` integer PRIMARY KEY AUTOINCREMENT,
20 20
                 `title` varchar(60) NOT NULL
21 21
             );";
22
-        self::$dbConnection->exec($createTable);
22
+		self::$dbConnection->exec($createTable);
23 23
 
24
-        $hydrateTable = "
24
+		$hydrateTable = "
25 25
             INSERT INTO `testing`
26 26
                 (`title`)
27 27
             VALUES
@@ -29,312 +29,312 @@  discard block
 block discarded – undo
29 29
                 ('beta'),
30 30
                 ('charlie'),
31 31
                 ('delta');";
32
-        self::$dbConnection->exec($hydrateTable);
33
-    }
34
-
35
-    public function testConstruct()
36
-    {
37
-        $startTime = microtime(true);
38
-
39
-        $profiler = new PhpQuickProfiler();
40
-        $this->assertAttributeEquals($startTime, 'startTime', $profiler);
41
-
42
-        $profiler = new PhpQuickProfiler($startTime);
43
-        $this->assertAttributeEquals($startTime, 'startTime', $profiler);
44
-    }
45
-
46
-    public function testSetConsole()
47
-    {
48
-        $console = new Console();
49
-        $profiler = new PhpQuickProfiler();
50
-        $profiler->setConsole($console);
51
-
52
-        $this->assertAttributeSame($console, 'console', $profiler);
53
-    }
54
-
55
-    public function testSetDisplay()
56
-    {
57
-        $display = new Display();
58
-        $profiler = new PhpQuickProfiler();
59
-        $profiler->setDisplay($display);
60
-
61
-        $this->assertAttributeSame($display, 'display', $profiler);
62
-    }
63
-
64
-    public function testGatherFileData()
65
-    {
66
-        $files = get_included_files();
67
-        $profiler = new PhpQuickProfiler();
68
-        $gatheredFileData = $profiler->gatherFileData();
69
-
70
-        $this->assertInternalType('array', $gatheredFileData);
71
-        $this->assertEquals(count($files), count($gatheredFileData));
72
-        foreach ($gatheredFileData as $fileData) {
73
-            $this->assertInternalType('array', $fileData);
74
-            $this->assertArrayHasKey('name', $fileData);
75
-            $this->assertContains($fileData['name'], $files);
76
-            $this->assertArrayHasKey('size', $fileData);
77
-            $this->assertEquals($fileData['size'], filesize($fileData['name']));
78
-        }
79
-    }
80
-
81
-    public function testGatherMemoryData()
82
-    {
83
-        $memoryUsage = memory_get_peak_usage();
84
-        $allowedLimit = ini_get('memory_limit');
85
-        $profiler = new PhpQuickProfiler();
86
-        $gatheredMemoryData = $profiler->gatherMemoryData();
87
-
88
-        $this->assertInternalType('array', $gatheredMemoryData);
89
-        $this->assertEquals(2, count($gatheredMemoryData));
90
-        $this->assertArrayHasKey('used', $gatheredMemoryData);
91
-        $this->assertEquals($memoryUsage, $gatheredMemoryData['used']);
92
-        $this->assertArrayHasKey('allowed', $gatheredMemoryData);
93
-        $this->assertEquals($allowedLimit, $gatheredMemoryData['allowed']);
94
-    }
95
-
96
-    public function testSetProfiledQueries()
97
-    {
98
-        $profiledQueries = $this->dataProfiledQueries();
99
-        $profiler = new PhpQuickProfiler();
100
-        $profiler->setProfiledQueries($profiledQueries);
101
-
102
-        $this->assertAttributeEquals($profiledQueries, 'profiledQueries', $profiler);
103
-    }
104
-
105
-    public function testGatherQueryData()
106
-    {
107
-        $profiledQueries = $this->dataProfiledQueries();
108
-        $profiledQueriesSql = array();
109
-        $profiledQueriesTime = array();
110
-        foreach ($profiledQueries as $queryData) {
111
-            array_push($profiledQueriesSql, $queryData['sql']);
112
-            array_push($profiledQueriesTime, $queryData['time']);
113
-        }
114
-
115
-        $profiler = new PhpQuickProfiler();
116
-        $profiler->setProfiledQueries($profiledQueries);
117
-        $gatheredQueryData = $profiler->gatherQueryData(self::$dbConnection);
118
-
119
-        $this->assertInternalType('array', $gatheredQueryData);
120
-        $this->assertEquals(count($profiledQueries), count($gatheredQueryData));
121
-        foreach ($gatheredQueryData as $queryData) {
122
-            $this->assertInternalType('array', $queryData);
123
-            $this->assertArrayHasKey('sql', $queryData);
124
-            $this->assertContains($queryData['sql'], $profiledQueriesSql);
125
-            $this->assertArrayHasKey('explain', $queryData);
126
-            $this->assertInternaltype('array', $queryData['explain']);
127
-            $this->assertGreaterThan(0, count($queryData['explain']));
128
-            $this->assertArrayHasKey('time', $queryData);
129
-            $this->assertContains($queryData['time'], $profiledQueriesTime);
130
-        }
131
-    }
132
-
133
-    public function testGatherQueryDataInternalProfiler()
134
-    {
135
-        $profiledQueries = $this->dataProfiledQueries();
136
-        $dbConnection = self::$dbConnection;
137
-        $dbConnection->queries = $profiledQueries;
138
-        $profiler = new PhpQuickProfiler();
139
-        $profiler->gatherQueryData($dbConnection);
140
-
141
-        $this->assertAttributeSame($profiledQueries, 'profiledQueries', $profiler);
142
-    }
143
-
144
-    /**
145
-     * @dataProvider dataProfiledQueries
146
-     */
147
-    public function testExplainQuery($sql, $parameters)
148
-    {
149
-        $profiler = new PhpQuickProfiler();
150
-        $reflectedMethod = $this->getAccessibleMethod($profiler, 'explainQuery');
151
-
152
-        $explainedQuery = $reflectedMethod->invokeArgs(
153
-            $profiler,
154
-            array(self::$dbConnection, $sql, $parameters)
155
-        );
156
-        $this->assertInternalType('array', $explainedQuery);
157
-        $this->assertGreaterThan(0, count($explainedQuery));
158
-    }
159
-
160
-    /**
161
-     * @expectedException Exception
162
-     */
163
-    public function testExplainQueryBadQueryException()
164
-    {
165
-        $invalidQuery = 'SELECT * FROM `fake_table`';
166
-        $profiler = new PhpQuickProfiler();
167
-        $reflectedMethod = $this->getAccessibleMethod($profiler, 'explainQuery');
168
-
169
-        $reflectedMethod->invokeArgs(
170
-            $profiler,
171
-            array(self::$dbConnection, $invalidQuery)
172
-        );
173
-    }
174
-
175
-    /**
176
-     * @expectedException Exception
177
-     */
178
-    public function testExplainQueryBadParametersException()
179
-    {
180
-        $query = 'SELECT * FROM `testing` WHERE `title` = :title';
181
-        $invalidParams = array('id' => 1);
182
-        $profiler = new PhpQuickProfiler();
183
-        $reflectedMethod = $this->getAccessibleMethod($profiler, 'explainQuery');
184
-
185
-        $reflectedMethod->invokeArgs(
186
-            $profiler,
187
-            array(self::$dbConnection, $query, $invalidParams)
188
-        );
189
-    }
190
-
191
-    /**
192
-     * @dataProvider dataConnectionDrivers
193
-     */
194
-    public function testGetExplainQuery($driver, $prefix)
195
-    {
196
-        $query = 'SELECT * FROM `testing`';
197
-        $profiler = new PhpQuickProfiler();
198
-        $reflectedMethod = $this->getAccessibleMethod($profiler, 'getExplainQuery');
199
-
200
-        $explainQuery = $reflectedMethod->invokeArgs(
201
-            $profiler,
202
-            array($query, $driver)
203
-        );
204
-
205
-        $explainPrefix = str_replace($query, '', $explainQuery);
206
-        $explainPrefix = trim($explainPrefix);
207
-        $this->assertEquals($prefix, $explainPrefix);
208
-    }
209
-
210
-    /**
211
-     * @expectedException Exception
212
-     */
213
-    public function testGetExplainQueryUnsupportedDriver()
214
-    {
215
-        $query = 'SELECT * FROM `testing`';
216
-        $unsupportedDriver = 'zz';
217
-        $profiler = new PhpQuickProfiler();
218
-        $reflectedMethod = $this->getAccessibleMethod($profiler, 'getExplainQuery');
219
-
220
-        $reflectedMethod->invokeArgs(
221
-            $profiler,
222
-            array($query, $unsupportedDriver)
223
-        );
224
-    }
225
-
226
-    public function testGatherSpeedData()
227
-    {
228
-        $elapsedTime = 1.234;
229
-        $startTime = microtime(true) - $elapsedTime;
230
-        $allowedTime = ini_get('max_execution_time');
231
-        $profiler = new PhpQuickProfiler($startTime);
232
-        $gatheredSpeedData = $profiler->gatherSpeedData();
233
-
234
-        $this->assertInternalType('array', $gatheredSpeedData);
235
-        $this->assertEquals(2, count($gatheredSpeedData));
236
-        $this->assertArrayHasKey('elapsed', $gatheredSpeedData);
237
-        $this->assertEquals($elapsedTime, $gatheredSpeedData['elapsed']);
238
-        $this->assertArrayHasKey('allowed', $gatheredSpeedData);
239
-        $this->assertEquals($allowedTime, $gatheredSpeedData['allowed']);
240
-    }
241
-
242
-    public function testDisplay()
243
-    {
244
-        $console = new Console();
245
-        $profiler = new PhpQuickProfiler();
246
-
247
-        $expectedDisplay = new Display();
248
-        $expectedDisplay->setConsole($console);
249
-        $expectedDisplay->setFileData($profiler->gatherFileData());
250
-        $expectedDisplay->setMemoryData($profiler->gatherMemoryData());
251
-        $expectedDisplay->setQueryData($profiler->gatherQueryData());
252
-        $expectedDisplay->setSpeedData($profiler->gatherSpeedData());
253
-        ob_start();
254
-        $expectedDisplay->__invoke();
255
-        ob_end_clean();
256
-
257
-        $display = new Display();
258
-        $profiler->setConsole($console);
259
-        $profiler->setDisplay($display);
260
-        ob_start();
261
-        $profiler->display();
262
-        ob_end_clean();
263
-
264
-        $this->assertAttributeEquals($expectedDisplay, 'display', $profiler);
265
-    }
266
-
267
-    /**
268
-     * @expectedException Exception
269
-     */
270
-    public function testDisplayNothingSetException()
271
-    {
272
-        $profiler = new PhpQuickProfiler();
273
-        $profiler->display();
274
-    }
275
-
276
-    /**
277
-     * @expectedException Exception
278
-     */
279
-    public function testDisplayNoConsoleException()
280
-    {
281
-        $display = new Display();
282
-        $profiler = new PhpQuickProfiler();
283
-        $profiler->setDisplay($display);
284
-        $profiler->display();
285
-    }
286
-
287
-    /**
288
-     * @expectedException Exception
289
-     */
290
-    public function testDisplayNoDisplayException()
291
-    {
292
-        $console = new Console();
293
-        $profiler = new PhpQuickProfiler();
294
-        $profiler->setConsole($console);
295
-        $profiler->display();
296
-    }
297
-
298
-    public function dataProfiledQueries()
299
-    {
300
-        return array(
301
-            array(
302
-              'sql' => "SELECT * FROM testing",
303
-              'parameters' => array(),
304
-              'time' => 25
305
-            ),
306
-            array(
307
-              'sql' => "SELECT id FROM testing WHERE title = :title",
308
-              'parameters' => array('title' => 'beta'),
309
-              'time' => 5
310
-            )
311
-        );
312
-    }
313
-
314
-    public function dataConnectionDrivers()
315
-    {
316
-        return array(
317
-            array(
318
-                'driver' => 'mysql',
319
-                'prefix' => 'EXPLAIN'
320
-            ),
321
-            array(
322
-                'driver' => 'sqlite',
323
-                'prefix' => 'EXPLAIN QUERY PLAN'
324
-            )
325
-        );
326
-    }
327
-
328
-    protected function getAccessibleMethod(PhpQuickProfiler $profiler, $methodName)
329
-    {
330
-        $reflectedConsole = new ReflectionClass(get_class($profiler));
331
-        $reflectedMethod = $reflectedConsole->getMethod($methodName);
332
-        $reflectedMethod->setAccessible(true);
333
-        return $reflectedMethod;
334
-    }
335
-
336
-    public static function tearDownAfterClass()
337
-    {
338
-        self::$dbConnection = null;
339
-    }
32
+		self::$dbConnection->exec($hydrateTable);
33
+	}
34
+
35
+	public function testConstruct()
36
+	{
37
+		$startTime = microtime(true);
38
+
39
+		$profiler = new PhpQuickProfiler();
40
+		$this->assertAttributeEquals($startTime, 'startTime', $profiler);
41
+
42
+		$profiler = new PhpQuickProfiler($startTime);
43
+		$this->assertAttributeEquals($startTime, 'startTime', $profiler);
44
+	}
45
+
46
+	public function testSetConsole()
47
+	{
48
+		$console = new Console();
49
+		$profiler = new PhpQuickProfiler();
50
+		$profiler->setConsole($console);
51
+
52
+		$this->assertAttributeSame($console, 'console', $profiler);
53
+	}
54
+
55
+	public function testSetDisplay()
56
+	{
57
+		$display = new Display();
58
+		$profiler = new PhpQuickProfiler();
59
+		$profiler->setDisplay($display);
60
+
61
+		$this->assertAttributeSame($display, 'display', $profiler);
62
+	}
63
+
64
+	public function testGatherFileData()
65
+	{
66
+		$files = get_included_files();
67
+		$profiler = new PhpQuickProfiler();
68
+		$gatheredFileData = $profiler->gatherFileData();
69
+
70
+		$this->assertInternalType('array', $gatheredFileData);
71
+		$this->assertEquals(count($files), count($gatheredFileData));
72
+		foreach ($gatheredFileData as $fileData) {
73
+			$this->assertInternalType('array', $fileData);
74
+			$this->assertArrayHasKey('name', $fileData);
75
+			$this->assertContains($fileData['name'], $files);
76
+			$this->assertArrayHasKey('size', $fileData);
77
+			$this->assertEquals($fileData['size'], filesize($fileData['name']));
78
+		}
79
+	}
80
+
81
+	public function testGatherMemoryData()
82
+	{
83
+		$memoryUsage = memory_get_peak_usage();
84
+		$allowedLimit = ini_get('memory_limit');
85
+		$profiler = new PhpQuickProfiler();
86
+		$gatheredMemoryData = $profiler->gatherMemoryData();
87
+
88
+		$this->assertInternalType('array', $gatheredMemoryData);
89
+		$this->assertEquals(2, count($gatheredMemoryData));
90
+		$this->assertArrayHasKey('used', $gatheredMemoryData);
91
+		$this->assertEquals($memoryUsage, $gatheredMemoryData['used']);
92
+		$this->assertArrayHasKey('allowed', $gatheredMemoryData);
93
+		$this->assertEquals($allowedLimit, $gatheredMemoryData['allowed']);
94
+	}
95
+
96
+	public function testSetProfiledQueries()
97
+	{
98
+		$profiledQueries = $this->dataProfiledQueries();
99
+		$profiler = new PhpQuickProfiler();
100
+		$profiler->setProfiledQueries($profiledQueries);
101
+
102
+		$this->assertAttributeEquals($profiledQueries, 'profiledQueries', $profiler);
103
+	}
104
+
105
+	public function testGatherQueryData()
106
+	{
107
+		$profiledQueries = $this->dataProfiledQueries();
108
+		$profiledQueriesSql = array();
109
+		$profiledQueriesTime = array();
110
+		foreach ($profiledQueries as $queryData) {
111
+			array_push($profiledQueriesSql, $queryData['sql']);
112
+			array_push($profiledQueriesTime, $queryData['time']);
113
+		}
114
+
115
+		$profiler = new PhpQuickProfiler();
116
+		$profiler->setProfiledQueries($profiledQueries);
117
+		$gatheredQueryData = $profiler->gatherQueryData(self::$dbConnection);
118
+
119
+		$this->assertInternalType('array', $gatheredQueryData);
120
+		$this->assertEquals(count($profiledQueries), count($gatheredQueryData));
121
+		foreach ($gatheredQueryData as $queryData) {
122
+			$this->assertInternalType('array', $queryData);
123
+			$this->assertArrayHasKey('sql', $queryData);
124
+			$this->assertContains($queryData['sql'], $profiledQueriesSql);
125
+			$this->assertArrayHasKey('explain', $queryData);
126
+			$this->assertInternaltype('array', $queryData['explain']);
127
+			$this->assertGreaterThan(0, count($queryData['explain']));
128
+			$this->assertArrayHasKey('time', $queryData);
129
+			$this->assertContains($queryData['time'], $profiledQueriesTime);
130
+		}
131
+	}
132
+
133
+	public function testGatherQueryDataInternalProfiler()
134
+	{
135
+		$profiledQueries = $this->dataProfiledQueries();
136
+		$dbConnection = self::$dbConnection;
137
+		$dbConnection->queries = $profiledQueries;
138
+		$profiler = new PhpQuickProfiler();
139
+		$profiler->gatherQueryData($dbConnection);
140
+
141
+		$this->assertAttributeSame($profiledQueries, 'profiledQueries', $profiler);
142
+	}
143
+
144
+	/**
145
+	 * @dataProvider dataProfiledQueries
146
+	 */
147
+	public function testExplainQuery($sql, $parameters)
148
+	{
149
+		$profiler = new PhpQuickProfiler();
150
+		$reflectedMethod = $this->getAccessibleMethod($profiler, 'explainQuery');
151
+
152
+		$explainedQuery = $reflectedMethod->invokeArgs(
153
+			$profiler,
154
+			array(self::$dbConnection, $sql, $parameters)
155
+		);
156
+		$this->assertInternalType('array', $explainedQuery);
157
+		$this->assertGreaterThan(0, count($explainedQuery));
158
+	}
159
+
160
+	/**
161
+	 * @expectedException Exception
162
+	 */
163
+	public function testExplainQueryBadQueryException()
164
+	{
165
+		$invalidQuery = 'SELECT * FROM `fake_table`';
166
+		$profiler = new PhpQuickProfiler();
167
+		$reflectedMethod = $this->getAccessibleMethod($profiler, 'explainQuery');
168
+
169
+		$reflectedMethod->invokeArgs(
170
+			$profiler,
171
+			array(self::$dbConnection, $invalidQuery)
172
+		);
173
+	}
174
+
175
+	/**
176
+	 * @expectedException Exception
177
+	 */
178
+	public function testExplainQueryBadParametersException()
179
+	{
180
+		$query = 'SELECT * FROM `testing` WHERE `title` = :title';
181
+		$invalidParams = array('id' => 1);
182
+		$profiler = new PhpQuickProfiler();
183
+		$reflectedMethod = $this->getAccessibleMethod($profiler, 'explainQuery');
184
+
185
+		$reflectedMethod->invokeArgs(
186
+			$profiler,
187
+			array(self::$dbConnection, $query, $invalidParams)
188
+		);
189
+	}
190
+
191
+	/**
192
+	 * @dataProvider dataConnectionDrivers
193
+	 */
194
+	public function testGetExplainQuery($driver, $prefix)
195
+	{
196
+		$query = 'SELECT * FROM `testing`';
197
+		$profiler = new PhpQuickProfiler();
198
+		$reflectedMethod = $this->getAccessibleMethod($profiler, 'getExplainQuery');
199
+
200
+		$explainQuery = $reflectedMethod->invokeArgs(
201
+			$profiler,
202
+			array($query, $driver)
203
+		);
204
+
205
+		$explainPrefix = str_replace($query, '', $explainQuery);
206
+		$explainPrefix = trim($explainPrefix);
207
+		$this->assertEquals($prefix, $explainPrefix);
208
+	}
209
+
210
+	/**
211
+	 * @expectedException Exception
212
+	 */
213
+	public function testGetExplainQueryUnsupportedDriver()
214
+	{
215
+		$query = 'SELECT * FROM `testing`';
216
+		$unsupportedDriver = 'zz';
217
+		$profiler = new PhpQuickProfiler();
218
+		$reflectedMethod = $this->getAccessibleMethod($profiler, 'getExplainQuery');
219
+
220
+		$reflectedMethod->invokeArgs(
221
+			$profiler,
222
+			array($query, $unsupportedDriver)
223
+		);
224
+	}
225
+
226
+	public function testGatherSpeedData()
227
+	{
228
+		$elapsedTime = 1.234;
229
+		$startTime = microtime(true) - $elapsedTime;
230
+		$allowedTime = ini_get('max_execution_time');
231
+		$profiler = new PhpQuickProfiler($startTime);
232
+		$gatheredSpeedData = $profiler->gatherSpeedData();
233
+
234
+		$this->assertInternalType('array', $gatheredSpeedData);
235
+		$this->assertEquals(2, count($gatheredSpeedData));
236
+		$this->assertArrayHasKey('elapsed', $gatheredSpeedData);
237
+		$this->assertEquals($elapsedTime, $gatheredSpeedData['elapsed']);
238
+		$this->assertArrayHasKey('allowed', $gatheredSpeedData);
239
+		$this->assertEquals($allowedTime, $gatheredSpeedData['allowed']);
240
+	}
241
+
242
+	public function testDisplay()
243
+	{
244
+		$console = new Console();
245
+		$profiler = new PhpQuickProfiler();
246
+
247
+		$expectedDisplay = new Display();
248
+		$expectedDisplay->setConsole($console);
249
+		$expectedDisplay->setFileData($profiler->gatherFileData());
250
+		$expectedDisplay->setMemoryData($profiler->gatherMemoryData());
251
+		$expectedDisplay->setQueryData($profiler->gatherQueryData());
252
+		$expectedDisplay->setSpeedData($profiler->gatherSpeedData());
253
+		ob_start();
254
+		$expectedDisplay->__invoke();
255
+		ob_end_clean();
256
+
257
+		$display = new Display();
258
+		$profiler->setConsole($console);
259
+		$profiler->setDisplay($display);
260
+		ob_start();
261
+		$profiler->display();
262
+		ob_end_clean();
263
+
264
+		$this->assertAttributeEquals($expectedDisplay, 'display', $profiler);
265
+	}
266
+
267
+	/**
268
+	 * @expectedException Exception
269
+	 */
270
+	public function testDisplayNothingSetException()
271
+	{
272
+		$profiler = new PhpQuickProfiler();
273
+		$profiler->display();
274
+	}
275
+
276
+	/**
277
+	 * @expectedException Exception
278
+	 */
279
+	public function testDisplayNoConsoleException()
280
+	{
281
+		$display = new Display();
282
+		$profiler = new PhpQuickProfiler();
283
+		$profiler->setDisplay($display);
284
+		$profiler->display();
285
+	}
286
+
287
+	/**
288
+	 * @expectedException Exception
289
+	 */
290
+	public function testDisplayNoDisplayException()
291
+	{
292
+		$console = new Console();
293
+		$profiler = new PhpQuickProfiler();
294
+		$profiler->setConsole($console);
295
+		$profiler->display();
296
+	}
297
+
298
+	public function dataProfiledQueries()
299
+	{
300
+		return array(
301
+			array(
302
+			  'sql' => "SELECT * FROM testing",
303
+			  'parameters' => array(),
304
+			  'time' => 25
305
+			),
306
+			array(
307
+			  'sql' => "SELECT id FROM testing WHERE title = :title",
308
+			  'parameters' => array('title' => 'beta'),
309
+			  'time' => 5
310
+			)
311
+		);
312
+	}
313
+
314
+	public function dataConnectionDrivers()
315
+	{
316
+		return array(
317
+			array(
318
+				'driver' => 'mysql',
319
+				'prefix' => 'EXPLAIN'
320
+			),
321
+			array(
322
+				'driver' => 'sqlite',
323
+				'prefix' => 'EXPLAIN QUERY PLAN'
324
+			)
325
+		);
326
+	}
327
+
328
+	protected function getAccessibleMethod(PhpQuickProfiler $profiler, $methodName)
329
+	{
330
+		$reflectedConsole = new ReflectionClass(get_class($profiler));
331
+		$reflectedMethod = $reflectedConsole->getMethod($methodName);
332
+		$reflectedMethod->setAccessible(true);
333
+		return $reflectedMethod;
334
+	}
335
+
336
+	public static function tearDownAfterClass()
337
+	{
338
+		self::$dbConnection = null;
339
+	}
340 340
 }
Please login to merge, or discard this patch.
src/PhpQuickProfiler.php 1 patch
Indentation   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -17,193 +17,193 @@
 block discarded – undo
17 17
 class PhpQuickProfiler
18 18
 {
19 19
 
20
-    /** @var  double */
21
-    protected $startTime;
22
-
23
-    /** @var  Console */
24
-    protected $console;
25
-
26
-    /** @var  Display */
27
-    protected $display;
28
-
29
-    /** @var  array */
30
-    protected $profiledQueries = array();
31
-
32
-    /**
33
-     * @param double $startTime
34
-     */
35
-    public function __construct($startTime = null)
36
-    {
37
-        if (is_null($startTime)) {
38
-            $startTime = microtime(true);
39
-        }
40
-        $this->startTime = $startTime;
41
-    }
42
-
43
-    /**
44
-     * @param Console $console
45
-     */
46
-    public function setConsole(Console $console)
47
-    {
48
-        $this->console = $console;
49
-    }
50
-
51
-    /**
52
-     * @param Display $display
53
-     */
54
-    public function setDisplay(Display $display)
55
-    {
56
-        $this->display = $display;
57
-    }
58
-
59
-    /**
60
-     * Get data about files loaded for the application to current point
61
-     *
62
-     * @returns array
63
-     */
64
-    public function gatherFileData()
65
-    {
66
-        $files = get_included_files();
67
-        $data = array();
68
-        foreach ($files as $file) {
69
-            array_push($data, array(
70
-                'name' => $file,
71
-                'size' => filesize($file)
72
-            ));
73
-        }
74
-        return $data;
75
-    }
76
-
77
-    /**
78
-     * Get data about memory usage of the application
79
-     *
80
-     * @returns array
81
-     */
82
-    public function gatherMemoryData()
83
-    {
84
-        $usedMemory = memory_get_peak_usage();
85
-        $allowedMemory = ini_get('memory_limit');
86
-        return array(
87
-            'used'    => $usedMemory,
88
-            'allowed' => $allowedMemory
89
-        );
90
-    }
91
-
92
-    /**
93
-     * @param array $profiledQueries
94
-     */
95
-    public function setProfiledQueries(array $profiledQueries)
96
-    {
97
-        $this->profiledQueries = $profiledQueries;
98
-    }
99
-
100
-    /**
101
-     * Get data about sql usage of the application
102
-     *
103
-     * @param object $dbConnection
104
-     * @returns array
105
-     */
106
-    public function gatherQueryData($dbConnection = null)
107
-    {
108
-        if (is_null($dbConnection)) {
109
-            return array();
110
-        }
111
-
112
-        if (empty($this->profiledQueries) && property_exists($dbConnection, 'queries')) {
113
-            $this->setProfiledQueries($dbConnection->queries);
114
-        }
115
-
116
-        $data = array();
117
-        foreach ($this->profiledQueries as $query) {
118
-            array_push($data, array(
119
-                'sql'     => $query['sql'],
120
-                'explain' => $this->explainQuery($dbConnection, $query['sql'], $query['parameters']),
121
-                'time'    => $query['time']
122
-            ));
123
-        }
124
-        return $data;
125
-    }
126
-
127
-    /**
128
-     * Attempts to explain a query
129
-     *
130
-     * @param object $dbConnection
131
-     * @param string $query
132
-     * @param array  $parameters
133
-     * @throws Exception
134
-     * @return array
135
-     */
136
-    protected function explainQuery($dbConnection, $query, $parameters = array())
137
-    {
138
-        $driver = $dbConnection->getAttribute(\PDO::ATTR_DRIVER_NAME);
139
-        $query = $this->getExplainQuery($query, $driver);
140
-        $statement = $dbConnection->prepare($query);
141
-        if ($statement === false) {
142
-            throw new Exception('Invalid query passed to explainQuery method');
143
-        }
144
-        $statement->execute($parameters);
145
-        $result = $statement->fetch(\PDO::FETCH_ASSOC);
146
-        if ($result === false) {
147
-            throw new Exception('Query could not be explained with given parameters');
148
-        }
149
-        return $result;
150
-    }
151
-
152
-    /**
153
-     * Attempts to figure out what kind of explain query format the db wants
154
-     *
155
-     * @param string $query
156
-     * @param string $driver
157
-     * @throws Exception
158
-     * @return string
159
-     */
160
-    protected function getExplainQuery($query, $driver)
161
-    {
162
-        if ($driver == 'mysql') {
163
-            return "EXPLAIN {$query}";
164
-        } elseif ($driver == 'sqlite') {
165
-            return "EXPLAIN QUERY PLAN {$query}";
166
-        }
167
-        throw new Exception('Could not process db driver');
168
-    }
169
-
170
-    /**
171
-     * Get data about speed of the application
172
-     *
173
-     * @returns array
174
-     */
175
-    public function gatherSpeedData()
176
-    {
177
-        $elapsedTime = microtime(true) - $this->startTime;
178
-        $elapsedTime = round($elapsedTime, 3);
179
-        $allowedTime = ini_get('max_execution_time');
180
-        return array(
181
-            'elapsed' => $elapsedTime,
182
-            'allowed' => $allowedTime
183
-        );
184
-    }
185
-
186
-    /**
187
-     * Triggers end display of the profiling data
188
-     *
189
-     * @param object $dbConnection
190
-     * @throws Exception
191
-     */
192
-    public function display($dbConnection = null)
193
-    {
194
-        if (!isset($this->display)) {
195
-            throw new Exception('Display object has not been injected into Profiler');
196
-        }
197
-        if (!isset($this->console)) {
198
-            throw new Exception('Console object has not been injected into Profiler');
199
-        }
200
-
201
-        $this->display->setConsole($this->console);
202
-        $this->display->setFileData($this->gatherFileData());
203
-        $this->display->setMemoryData($this->gatherMemoryData());
204
-        $this->display->setQueryData($this->gatherQueryData($dbConnection));
205
-        $this->display->setSpeedData($this->gatherSpeedData());
206
-
207
-        $this->display->__invoke();
208
-    }
20
+	/** @var  double */
21
+	protected $startTime;
22
+
23
+	/** @var  Console */
24
+	protected $console;
25
+
26
+	/** @var  Display */
27
+	protected $display;
28
+
29
+	/** @var  array */
30
+	protected $profiledQueries = array();
31
+
32
+	/**
33
+	 * @param double $startTime
34
+	 */
35
+	public function __construct($startTime = null)
36
+	{
37
+		if (is_null($startTime)) {
38
+			$startTime = microtime(true);
39
+		}
40
+		$this->startTime = $startTime;
41
+	}
42
+
43
+	/**
44
+	 * @param Console $console
45
+	 */
46
+	public function setConsole(Console $console)
47
+	{
48
+		$this->console = $console;
49
+	}
50
+
51
+	/**
52
+	 * @param Display $display
53
+	 */
54
+	public function setDisplay(Display $display)
55
+	{
56
+		$this->display = $display;
57
+	}
58
+
59
+	/**
60
+	 * Get data about files loaded for the application to current point
61
+	 *
62
+	 * @returns array
63
+	 */
64
+	public function gatherFileData()
65
+	{
66
+		$files = get_included_files();
67
+		$data = array();
68
+		foreach ($files as $file) {
69
+			array_push($data, array(
70
+				'name' => $file,
71
+				'size' => filesize($file)
72
+			));
73
+		}
74
+		return $data;
75
+	}
76
+
77
+	/**
78
+	 * Get data about memory usage of the application
79
+	 *
80
+	 * @returns array
81
+	 */
82
+	public function gatherMemoryData()
83
+	{
84
+		$usedMemory = memory_get_peak_usage();
85
+		$allowedMemory = ini_get('memory_limit');
86
+		return array(
87
+			'used'    => $usedMemory,
88
+			'allowed' => $allowedMemory
89
+		);
90
+	}
91
+
92
+	/**
93
+	 * @param array $profiledQueries
94
+	 */
95
+	public function setProfiledQueries(array $profiledQueries)
96
+	{
97
+		$this->profiledQueries = $profiledQueries;
98
+	}
99
+
100
+	/**
101
+	 * Get data about sql usage of the application
102
+	 *
103
+	 * @param object $dbConnection
104
+	 * @returns array
105
+	 */
106
+	public function gatherQueryData($dbConnection = null)
107
+	{
108
+		if (is_null($dbConnection)) {
109
+			return array();
110
+		}
111
+
112
+		if (empty($this->profiledQueries) && property_exists($dbConnection, 'queries')) {
113
+			$this->setProfiledQueries($dbConnection->queries);
114
+		}
115
+
116
+		$data = array();
117
+		foreach ($this->profiledQueries as $query) {
118
+			array_push($data, array(
119
+				'sql'     => $query['sql'],
120
+				'explain' => $this->explainQuery($dbConnection, $query['sql'], $query['parameters']),
121
+				'time'    => $query['time']
122
+			));
123
+		}
124
+		return $data;
125
+	}
126
+
127
+	/**
128
+	 * Attempts to explain a query
129
+	 *
130
+	 * @param object $dbConnection
131
+	 * @param string $query
132
+	 * @param array  $parameters
133
+	 * @throws Exception
134
+	 * @return array
135
+	 */
136
+	protected function explainQuery($dbConnection, $query, $parameters = array())
137
+	{
138
+		$driver = $dbConnection->getAttribute(\PDO::ATTR_DRIVER_NAME);
139
+		$query = $this->getExplainQuery($query, $driver);
140
+		$statement = $dbConnection->prepare($query);
141
+		if ($statement === false) {
142
+			throw new Exception('Invalid query passed to explainQuery method');
143
+		}
144
+		$statement->execute($parameters);
145
+		$result = $statement->fetch(\PDO::FETCH_ASSOC);
146
+		if ($result === false) {
147
+			throw new Exception('Query could not be explained with given parameters');
148
+		}
149
+		return $result;
150
+	}
151
+
152
+	/**
153
+	 * Attempts to figure out what kind of explain query format the db wants
154
+	 *
155
+	 * @param string $query
156
+	 * @param string $driver
157
+	 * @throws Exception
158
+	 * @return string
159
+	 */
160
+	protected function getExplainQuery($query, $driver)
161
+	{
162
+		if ($driver == 'mysql') {
163
+			return "EXPLAIN {$query}";
164
+		} elseif ($driver == 'sqlite') {
165
+			return "EXPLAIN QUERY PLAN {$query}";
166
+		}
167
+		throw new Exception('Could not process db driver');
168
+	}
169
+
170
+	/**
171
+	 * Get data about speed of the application
172
+	 *
173
+	 * @returns array
174
+	 */
175
+	public function gatherSpeedData()
176
+	{
177
+		$elapsedTime = microtime(true) - $this->startTime;
178
+		$elapsedTime = round($elapsedTime, 3);
179
+		$allowedTime = ini_get('max_execution_time');
180
+		return array(
181
+			'elapsed' => $elapsedTime,
182
+			'allowed' => $allowedTime
183
+		);
184
+	}
185
+
186
+	/**
187
+	 * Triggers end display of the profiling data
188
+	 *
189
+	 * @param object $dbConnection
190
+	 * @throws Exception
191
+	 */
192
+	public function display($dbConnection = null)
193
+	{
194
+		if (!isset($this->display)) {
195
+			throw new Exception('Display object has not been injected into Profiler');
196
+		}
197
+		if (!isset($this->console)) {
198
+			throw new Exception('Console object has not been injected into Profiler');
199
+		}
200
+
201
+		$this->display->setConsole($this->console);
202
+		$this->display->setFileData($this->gatherFileData());
203
+		$this->display->setMemoryData($this->gatherMemoryData());
204
+		$this->display->setQueryData($this->gatherQueryData($dbConnection));
205
+		$this->display->setSpeedData($this->gatherSpeedData());
206
+
207
+		$this->display->__invoke();
208
+	}
209 209
 }
Please login to merge, or discard this patch.
tests/unit/DisplayTest.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -8,64 +8,64 @@
 block discarded – undo
8 8
 class DisplayTest extends PHPUnit_Framework_TestCase
9 9
 {
10 10
 
11
-    public function testConstruct()
12
-    {
13
-        $display = new Display();
14
-        $reflectedDisplay = new ReflectionClass(get_class($display));
15
-        $reflectedProperty = $reflectedDisplay->getProperty('defaults');
16
-        $reflectedProperty->setAccessible(true);
17
-        $defaults = $reflectedProperty->getValue($display);
11
+	public function testConstruct()
12
+	{
13
+		$display = new Display();
14
+		$reflectedDisplay = new ReflectionClass(get_class($display));
15
+		$reflectedProperty = $reflectedDisplay->getProperty('defaults');
16
+		$reflectedProperty->setAccessible(true);
17
+		$defaults = $reflectedProperty->getValue($display);
18 18
 
19
-        $display = new Display();
20
-        $this->assertAttributeEquals($defaults, 'options', $display);
19
+		$display = new Display();
20
+		$this->assertAttributeEquals($defaults, 'options', $display);
21 21
 
22
-        $options = array(
23
-            'script_path' => 'testing/testing.js',
24
-            'fake_key' => 'foo bar'
25
-        );
26
-        $expectedOptions = array_intersect_key($options, $defaults);
27
-        $expectedOptions = array_replace($defaults, $expectedOptions);
28
-        $display = new Display($options);
29
-        $this->assertAttributeEquals($expectedOptions, 'options', $display);
30
-    }
22
+		$options = array(
23
+			'script_path' => 'testing/testing.js',
24
+			'fake_key' => 'foo bar'
25
+		);
26
+		$expectedOptions = array_intersect_key($options, $defaults);
27
+		$expectedOptions = array_replace($defaults, $expectedOptions);
28
+		$display = new Display($options);
29
+		$this->assertAttributeEquals($expectedOptions, 'options', $display);
30
+	}
31 31
 
32
-    public function testGetReadableTime()
33
-    {
34
-        $timeTest = array(
35
-            '.032432' => '32.432 ms',
36
-            '24.3781' => '24.378 s',
37
-            '145.123' => '2.419 m'
38
-        );
39
-        $display = new Display();
40
-        $reflectedMethod = $this->getAccessibleMethod($display, 'getReadableTime');
32
+	public function testGetReadableTime()
33
+	{
34
+		$timeTest = array(
35
+			'.032432' => '32.432 ms',
36
+			'24.3781' => '24.378 s',
37
+			'145.123' => '2.419 m'
38
+		);
39
+		$display = new Display();
40
+		$reflectedMethod = $this->getAccessibleMethod($display, 'getReadableTime');
41 41
 
42
-        foreach ($timeTest as $rawTime => $expectedTime) {
43
-            $readableTime = $reflectedMethod->invokeArgs($display, array($rawTime));
44
-            $this->assertEquals($expectedTime, $readableTime);
45
-        }
46
-    }
42
+		foreach ($timeTest as $rawTime => $expectedTime) {
43
+			$readableTime = $reflectedMethod->invokeArgs($display, array($rawTime));
44
+			$this->assertEquals($expectedTime, $readableTime);
45
+		}
46
+	}
47 47
 
48
-    public function testGetReadableMemory()
49
-    {
50
-        $memoryTest = array(
51
-            '314'     => '314 b',
52
-            '7403'    => '7.23 k',
53
-            '2589983' => '2.47 M'
54
-        );
55
-        $display = new Display();
56
-        $reflectedMethod = $this->getAccessibleMethod($display, 'getReadableMemory');
48
+	public function testGetReadableMemory()
49
+	{
50
+		$memoryTest = array(
51
+			'314'     => '314 b',
52
+			'7403'    => '7.23 k',
53
+			'2589983' => '2.47 M'
54
+		);
55
+		$display = new Display();
56
+		$reflectedMethod = $this->getAccessibleMethod($display, 'getReadableMemory');
57 57
 
58
-        foreach ($memoryTest as $rawMemory => $expectedMemory) {
59
-            $readableMemory = $reflectedMethod->invokeArgs($display, array($rawMemory));
60
-            $this->assertEquals($expectedMemory, $readableMemory);
61
-        }
62
-    }
58
+		foreach ($memoryTest as $rawMemory => $expectedMemory) {
59
+			$readableMemory = $reflectedMethod->invokeArgs($display, array($rawMemory));
60
+			$this->assertEquals($expectedMemory, $readableMemory);
61
+		}
62
+	}
63 63
 
64
-    protected function getAccessibleMethod(Display $display, $methodName)
65
-    {
66
-        $reflectedConsole = new ReflectionClass(get_class($display));
67
-        $reflectedMethod = $reflectedConsole->getMethod($methodName);
68
-        $reflectedMethod->setAccessible(true);
69
-        return $reflectedMethod;
70
-    }
64
+	protected function getAccessibleMethod(Display $display, $methodName)
65
+	{
66
+		$reflectedConsole = new ReflectionClass(get_class($display));
67
+		$reflectedMethod = $reflectedConsole->getMethod($methodName);
68
+		$reflectedMethod->setAccessible(true);
69
+		return $reflectedMethod;
70
+	}
71 71
 }
Please login to merge, or discard this patch.
src/Display.php 1 patch
Indentation   +300 added lines, -300 removed lines patch added patch discarded remove patch
@@ -14,305 +14,305 @@
 block discarded – undo
14 14
 class Display
15 15
 {
16 16
 
17
-    /** @var  array */
18
-    protected $defaults = array(
19
-        'script_path' => 'asset/script.js',
20
-        'style_path'  => 'asset/style.css'
21
-    );
22
-
23
-    /** @var  array */
24
-    protected $options;
25
-
26
-    /** @var  Console */
27
-    protected $console;
28
-
29
-    /** @var  array */
30
-    protected $speedData;
31
-
32
-    /** @var  array */
33
-    protected $queryData;
34
-
35
-    /** @var  array */
36
-    protected $memoryData;
37
-
38
-    /** @var  array */
39
-    protected $fileData;
40
-
41
-    /**
42
-     * @param array $options
43
-     */
44
-    public function __construct(array $options = array())
45
-    {
46
-        $options = array_intersect_key($options, $this->defaults);
47
-        $this->options = array_replace($this->defaults, $options);
48
-    }
49
-
50
-    /**
51
-     * @param Console $console
52
-     */
53
-    public function setConsole(Console $console)
54
-    {
55
-        $this->console = $console;
56
-    }
57
-
58
-    /**
59
-     * @return array
60
-     */
61
-    protected function formatConsoleData()
62
-    {
63
-        $console_data = array(
64
-            'messages' => array(),
65
-            'meta'    => array(
66
-                'log'    => 0,
67
-                'memory' => 0,
68
-                'error'  => 0,
69
-                'speed'  => 0
70
-            )
71
-        );
72
-        foreach ($this->console->getLogs() as $log) {
73
-            switch($log['type']) {
74
-                case 'log':
75
-                    $message = array(
76
-                        'message' => print_r($log['data'], true),
77
-                        'type'    => 'log'
78
-                    );
79
-                    $console_data['meta']['log']++;
80
-                    break;
81
-                case 'memory':
82
-                    $message = array(
83
-                        'message' => (!empty($log['data_type']) ? "{$log['data_type']}: " : '') . $log['name'],
84
-                        'data'    => $this->getReadableMemory($log['data']),
85
-                        'type'    => 'memory'
86
-                    );
87
-                    $console_data['meta']['memory']++;
88
-                    break;
89
-                case 'error':
90
-                    $message = array(
91
-                        'message' => "Line {$log['line']}: {$log['data']} in {$log['file']}",
92
-                        'type'    => 'error'
93
-                    );
94
-                    $console_data['meta']['error']++;
95
-                    break;
96
-                case 'speed':
97
-                    $elapsedTime = $log['data'] - $this->startTime;
98
-                    $message = array(
99
-                        'message' => $log['name'],
100
-                        'data'    => $this->getReadableTime($elapsedTime),
101
-                        'type'    => 'speed'
102
-                    );
103
-                    $console_data['meta']['speed']++;
104
-                    break;
105
-                default:
106
-                    $message = array(
107
-                        'message' => "Unrecognized console log type: {$log['type']}",
108
-                        'type'    => 'error'
109
-                    );
110
-                    $console_data['meta']['error']++;
111
-                    break;
112
-            }
113
-            array_push($console_data['messages'], $message);
114
-        }
115
-        return $console_data;
116
-    }
117
-
118
-    /**
119
-     * Sets file data
120
-     *
121
-     * @param array $data
122
-     */
123
-    public function setFileData(array $data)
124
-    {
125
-        $this->fileData = $data;
126
-    }
127
-
128
-    /**
129
-     * @return array
130
-     */
131
-    protected function formatFileData()
132
-    {
133
-        $fileData = array(
134
-            'messages' => array(),
135
-            'meta'     => array(
136
-                'count'   => count($this->fileData),
137
-                'size'    => 0,
138
-                'largest' => 0
139
-            )
140
-        );
141
-
142
-        foreach ($this->fileData as $file) {
143
-            array_push($fileData['messages'], array(
144
-                'message' => $file['name'],
145
-                'data'    => $this->getReadableMemory($file['size'])
146
-            ));
147
-
148
-            $fileData['meta']['size'] += $file['size'];
149
-            if ($file['size'] > $fileData['meta']['largest']) {
150
-                $fileData['meta']['largest'] = $file['size'];
151
-            }
152
-        }
153
-
154
-        $fileData['meta']['size'] = $this->getReadableMemory($fileData['meta']['size']);
155
-        $fileData['meta']['largest'] = $this->getReadableMemory($fileData['meta']['largest']);
156
-
157
-        return $fileData;
158
-    }
159
-
160
-    /**
161
-     * Sets memory data
162
-     *
163
-     * @param array $data
164
-     */
165
-    public function setMemoryData(array $data)
166
-    {
167
-        $this->memoryData = $data;
168
-    }
169
-
170
-    /**
171
-     * @return array
172
-     */
173
-    public function formatMemoryData()
174
-    {
175
-        return array(
176
-            'meta' => array(
177
-                'used'    => $this->getReadableMemory($this->memoryData['used']),
178
-                'allowed' => $this->memoryData['allowed']
179
-            )
180
-        );
181
-    }
182
-
183
-    /**
184
-     * Sets query data
185
-     *
186
-     * @param array $data
187
-     */
188
-    public function setQueryData(array $data)
189
-    {
190
-        $this->queryData = $data;
191
-    }
192
-
193
-    /**
194
-     * @return array
195
-     */
196
-    public function formatQueryData()
197
-    {
198
-        $queryData = array(
199
-            'messages' => array(),
200
-            'meta'     => array(
201
-                'count'   => count($this->queryData),
202
-                'time'    => 0,
203
-                'slowest' => 0
204
-            )
205
-        );
206
-
207
-        foreach ($this->queryData as $query) {
208
-            array_push($queryData['messages'], array(
209
-                'message'  => $query['sql'],
210
-                'sub_data' => array_filter($query['explain']),
211
-                'data'     => $this->getReadableTime($query['time'])
212
-            ));
213
-            $queryData['meta']['time'] += $query['time'];
214
-            if ($query['time'] > $queryData['meta']['slowest']) {
215
-                $queryData['meta']['slowest'] = $query['time'];
216
-            }
217
-        }
218
-
219
-        $queryData['meta']['time'] = $this->getReadableTime($queryData['meta']['time']);
220
-        $queryData['meta']['slowest'] = $this->getReadableTime($queryData['meta']['slowest']);
221
-
222
-        return $queryData;
223
-    }
224
-
225
-    /**
226
-     * Sets speed data
227
-     *
228
-     * @param array $data
229
-     */
230
-    public function setSpeedData(array $data)
231
-    {
232
-        $this->speedData = $data;
233
-    }
234
-
235
-    /**
236
-     * @return array
237
-     */
238
-    protected function formatSpeedData()
239
-    {
240
-        return array(
241
-            'meta' => array(
242
-              'elapsed' => $this->getReadableTime($this->speedData['elapsed']),
243
-              'allowed' => $this->getReadableTime($this->speedData['allowed'], 0)
244
-            )
245
-        );
246
-    }
247
-
248
-    /**
249
-     * Formatter for human-readable time
250
-     * Only handles time up to 60 minutes gracefully
251
-     *
252
-     * @param double  $time
253
-     * @param integer $percision
254
-     * @return string
255
-     */
256
-    protected function getReadableTime($time, $percision = 3)
257
-    {
258
-        $unit = 's';
259
-        if ($time < 1) {
260
-            $time *= 1000;
261
-            $unit = 'ms';
262
-        } else if ($time > 60) {
263
-            $time /= 60;
264
-            $unit = 'm';
265
-        }
266
-        $time = number_format($time, $percision);
267
-        return "{$time} {$unit}";
268
-    }
269
-
270
-    /**
271
-     * Formatter for human-readable memory
272
-     * Only handles time up to a few gigs gracefully
273
-     *
274
-     * @param double  $size
275
-     * @param integer $percision
276
-     */
277
-    protected function getReadableMemory($size, $percision = 2)
278
-    {
279
-        $unitOptions = array('b', 'k', 'M', 'G');
280
-
281
-        $base = log($size, 1024);
282
-
283
-        $memory = round(pow(1024, $base - floor($base)), $percision);
284
-        $unit = $unitOptions[floor($base)];
285
-        return "{$memory} {$unit}";
286
-    }
17
+	/** @var  array */
18
+	protected $defaults = array(
19
+		'script_path' => 'asset/script.js',
20
+		'style_path'  => 'asset/style.css'
21
+	);
22
+
23
+	/** @var  array */
24
+	protected $options;
25
+
26
+	/** @var  Console */
27
+	protected $console;
28
+
29
+	/** @var  array */
30
+	protected $speedData;
31
+
32
+	/** @var  array */
33
+	protected $queryData;
34
+
35
+	/** @var  array */
36
+	protected $memoryData;
37
+
38
+	/** @var  array */
39
+	protected $fileData;
40
+
41
+	/**
42
+	 * @param array $options
43
+	 */
44
+	public function __construct(array $options = array())
45
+	{
46
+		$options = array_intersect_key($options, $this->defaults);
47
+		$this->options = array_replace($this->defaults, $options);
48
+	}
49
+
50
+	/**
51
+	 * @param Console $console
52
+	 */
53
+	public function setConsole(Console $console)
54
+	{
55
+		$this->console = $console;
56
+	}
57
+
58
+	/**
59
+	 * @return array
60
+	 */
61
+	protected function formatConsoleData()
62
+	{
63
+		$console_data = array(
64
+			'messages' => array(),
65
+			'meta'    => array(
66
+				'log'    => 0,
67
+				'memory' => 0,
68
+				'error'  => 0,
69
+				'speed'  => 0
70
+			)
71
+		);
72
+		foreach ($this->console->getLogs() as $log) {
73
+			switch($log['type']) {
74
+				case 'log':
75
+					$message = array(
76
+						'message' => print_r($log['data'], true),
77
+						'type'    => 'log'
78
+					);
79
+					$console_data['meta']['log']++;
80
+					break;
81
+				case 'memory':
82
+					$message = array(
83
+						'message' => (!empty($log['data_type']) ? "{$log['data_type']}: " : '') . $log['name'],
84
+						'data'    => $this->getReadableMemory($log['data']),
85
+						'type'    => 'memory'
86
+					);
87
+					$console_data['meta']['memory']++;
88
+					break;
89
+				case 'error':
90
+					$message = array(
91
+						'message' => "Line {$log['line']}: {$log['data']} in {$log['file']}",
92
+						'type'    => 'error'
93
+					);
94
+					$console_data['meta']['error']++;
95
+					break;
96
+				case 'speed':
97
+					$elapsedTime = $log['data'] - $this->startTime;
98
+					$message = array(
99
+						'message' => $log['name'],
100
+						'data'    => $this->getReadableTime($elapsedTime),
101
+						'type'    => 'speed'
102
+					);
103
+					$console_data['meta']['speed']++;
104
+					break;
105
+				default:
106
+					$message = array(
107
+						'message' => "Unrecognized console log type: {$log['type']}",
108
+						'type'    => 'error'
109
+					);
110
+					$console_data['meta']['error']++;
111
+					break;
112
+			}
113
+			array_push($console_data['messages'], $message);
114
+		}
115
+		return $console_data;
116
+	}
117
+
118
+	/**
119
+	 * Sets file data
120
+	 *
121
+	 * @param array $data
122
+	 */
123
+	public function setFileData(array $data)
124
+	{
125
+		$this->fileData = $data;
126
+	}
127
+
128
+	/**
129
+	 * @return array
130
+	 */
131
+	protected function formatFileData()
132
+	{
133
+		$fileData = array(
134
+			'messages' => array(),
135
+			'meta'     => array(
136
+				'count'   => count($this->fileData),
137
+				'size'    => 0,
138
+				'largest' => 0
139
+			)
140
+		);
141
+
142
+		foreach ($this->fileData as $file) {
143
+			array_push($fileData['messages'], array(
144
+				'message' => $file['name'],
145
+				'data'    => $this->getReadableMemory($file['size'])
146
+			));
147
+
148
+			$fileData['meta']['size'] += $file['size'];
149
+			if ($file['size'] > $fileData['meta']['largest']) {
150
+				$fileData['meta']['largest'] = $file['size'];
151
+			}
152
+		}
153
+
154
+		$fileData['meta']['size'] = $this->getReadableMemory($fileData['meta']['size']);
155
+		$fileData['meta']['largest'] = $this->getReadableMemory($fileData['meta']['largest']);
156
+
157
+		return $fileData;
158
+	}
159
+
160
+	/**
161
+	 * Sets memory data
162
+	 *
163
+	 * @param array $data
164
+	 */
165
+	public function setMemoryData(array $data)
166
+	{
167
+		$this->memoryData = $data;
168
+	}
169
+
170
+	/**
171
+	 * @return array
172
+	 */
173
+	public function formatMemoryData()
174
+	{
175
+		return array(
176
+			'meta' => array(
177
+				'used'    => $this->getReadableMemory($this->memoryData['used']),
178
+				'allowed' => $this->memoryData['allowed']
179
+			)
180
+		);
181
+	}
182
+
183
+	/**
184
+	 * Sets query data
185
+	 *
186
+	 * @param array $data
187
+	 */
188
+	public function setQueryData(array $data)
189
+	{
190
+		$this->queryData = $data;
191
+	}
192
+
193
+	/**
194
+	 * @return array
195
+	 */
196
+	public function formatQueryData()
197
+	{
198
+		$queryData = array(
199
+			'messages' => array(),
200
+			'meta'     => array(
201
+				'count'   => count($this->queryData),
202
+				'time'    => 0,
203
+				'slowest' => 0
204
+			)
205
+		);
206
+
207
+		foreach ($this->queryData as $query) {
208
+			array_push($queryData['messages'], array(
209
+				'message'  => $query['sql'],
210
+				'sub_data' => array_filter($query['explain']),
211
+				'data'     => $this->getReadableTime($query['time'])
212
+			));
213
+			$queryData['meta']['time'] += $query['time'];
214
+			if ($query['time'] > $queryData['meta']['slowest']) {
215
+				$queryData['meta']['slowest'] = $query['time'];
216
+			}
217
+		}
218
+
219
+		$queryData['meta']['time'] = $this->getReadableTime($queryData['meta']['time']);
220
+		$queryData['meta']['slowest'] = $this->getReadableTime($queryData['meta']['slowest']);
221
+
222
+		return $queryData;
223
+	}
224
+
225
+	/**
226
+	 * Sets speed data
227
+	 *
228
+	 * @param array $data
229
+	 */
230
+	public function setSpeedData(array $data)
231
+	{
232
+		$this->speedData = $data;
233
+	}
234
+
235
+	/**
236
+	 * @return array
237
+	 */
238
+	protected function formatSpeedData()
239
+	{
240
+		return array(
241
+			'meta' => array(
242
+			  'elapsed' => $this->getReadableTime($this->speedData['elapsed']),
243
+			  'allowed' => $this->getReadableTime($this->speedData['allowed'], 0)
244
+			)
245
+		);
246
+	}
247
+
248
+	/**
249
+	 * Formatter for human-readable time
250
+	 * Only handles time up to 60 minutes gracefully
251
+	 *
252
+	 * @param double  $time
253
+	 * @param integer $percision
254
+	 * @return string
255
+	 */
256
+	protected function getReadableTime($time, $percision = 3)
257
+	{
258
+		$unit = 's';
259
+		if ($time < 1) {
260
+			$time *= 1000;
261
+			$unit = 'ms';
262
+		} else if ($time > 60) {
263
+			$time /= 60;
264
+			$unit = 'm';
265
+		}
266
+		$time = number_format($time, $percision);
267
+		return "{$time} {$unit}";
268
+	}
269
+
270
+	/**
271
+	 * Formatter for human-readable memory
272
+	 * Only handles time up to a few gigs gracefully
273
+	 *
274
+	 * @param double  $size
275
+	 * @param integer $percision
276
+	 */
277
+	protected function getReadableMemory($size, $percision = 2)
278
+	{
279
+		$unitOptions = array('b', 'k', 'M', 'G');
280
+
281
+		$base = log($size, 1024);
282
+
283
+		$memory = round(pow(1024, $base - floor($base)), $percision);
284
+		$unit = $unitOptions[floor($base)];
285
+		return "{$memory} {$unit}";
286
+	}
287 287
  
288
-    public function __invoke()
289
-    {
290
-        $console= $this->formatConsoleData();
291
-        $speed= $this->formatSpeedData();
292
-        $query= $this->formatQueryData();
293
-        $memory= $this->formatMemoryData();
294
-        $files= $this->formatFileData();
295
-
296
-        $header = array(
297
-          'console' => count($console['messages']),
298
-          'speed'   => $speed['meta']['elapsed'],
299
-          'query'   => $query['meta']['count'],
300
-          'memory'  => $memory['meta']['used'],
301
-          'files'   => $files['meta']['count']
302
-        );
303
-
304
-        $speed['messages'] = array_filter($console['messages'], function ($message) {
305
-            return $message['type'] == 'speed';
306
-        });
307
-
308
-        $memory['messages'] = array_filter($console['messages'], function ($message) {
309
-            return $message['type'] == 'memory';
310
-        });
311
-
312
-        // todo is this really the best way to load these?
313
-        $styles = file_get_contents(__DIR__ . "./../{$this->options['style_path']}");
314
-        $script = file_get_contents(__DIR__ . "./../{$this->options['script_path']}");
315
-
316
-        require_once __DIR__ .'/../asset/display.html';
317
-    }
288
+	public function __invoke()
289
+	{
290
+		$console= $this->formatConsoleData();
291
+		$speed= $this->formatSpeedData();
292
+		$query= $this->formatQueryData();
293
+		$memory= $this->formatMemoryData();
294
+		$files= $this->formatFileData();
295
+
296
+		$header = array(
297
+		  'console' => count($console['messages']),
298
+		  'speed'   => $speed['meta']['elapsed'],
299
+		  'query'   => $query['meta']['count'],
300
+		  'memory'  => $memory['meta']['used'],
301
+		  'files'   => $files['meta']['count']
302
+		);
303
+
304
+		$speed['messages'] = array_filter($console['messages'], function ($message) {
305
+			return $message['type'] == 'speed';
306
+		});
307
+
308
+		$memory['messages'] = array_filter($console['messages'], function ($message) {
309
+			return $message['type'] == 'memory';
310
+		});
311
+
312
+		// todo is this really the best way to load these?
313
+		$styles = file_get_contents(__DIR__ . "./../{$this->options['style_path']}");
314
+		$script = file_get_contents(__DIR__ . "./../{$this->options['script_path']}");
315
+
316
+		require_once __DIR__ .'/../asset/display.html';
317
+	}
318 318
 }	
Please login to merge, or discard this patch.