Skip to content

Commit 3192984

Browse files
author
Xavier Barbosa
committed
Request and Route renderer.
1 parent 3b76c7a commit 3192984

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

src/Renderers/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Madewithlove\LaravelDebugConsole\Renderers;
44

5-
class Messages extends AbstractRenderer
5+
class Message extends AbstractRenderer
66
{
77
/**
88
* @param array $data

src/Renderers/Request.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,23 @@
22

33
namespace Madewithlove\LaravelDebugConsole\Renderers;
44

5-
use Symfony\Component\Console\Helper\Table;
6-
75
class Request extends AbstractRenderer
86
{
97
/**
108
* @param array $data
119
*/
1210
public function render(array $data)
1311
{
14-
$this->output->writeln('Request information:');
12+
$this->output->title('Route');
13+
14+
$request = array_get($data, 'request', []);
15+
16+
$this->output->table([], array_map(function ($value, $index) {
17+
if (is_array($value)) {
18+
$value = implode(', ', $value);
19+
}
1520

16-
$table = new Table($this->output);
17-
$table->setHeaders([
18-
'Date and Time',
19-
'Total Memory',
20-
'Total Time',
21-
])
22-
->setRows([
23-
[
24-
array_get($data, '__meta.datetime'),
25-
array_get($data, 'memory.peak_usage_str'),
26-
array_get($data, 'time.duration_str')
27-
],
28-
])
29-
->render();
21+
return [$index, str_limit($value, 200)];
22+
}, array_values($request), array_keys($request)));
3023
}
3124
}

src/Renderers/Route.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Madewithlove\LaravelDebugConsole\Renderers;
4+
5+
class Route extends AbstractRenderer
6+
{
7+
/**
8+
* @param array $data
9+
*/
10+
public function render(array $data)
11+
{
12+
$this->output->title('Route');
13+
14+
$route = array_get($data, 'route', []);
15+
16+
$this->output->table([], array_map(function ($value, $index) {
17+
if (is_array($value)) {
18+
$value = implode(', ', $value);
19+
}
20+
21+
return [$index, str_limit($value, 200)];
22+
}, array_values($route), array_keys($route)));
23+
}
24+
}

0 commit comments

Comments
 (0)