PluginProbe
Depicter — Popup & Slider Builder / 1.6.2
Depicter — Popup & Slider Builder v1.6.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / vendor / htmlburger / wpemerge / src / Exceptions / Whoops / DebugDataProvider.php

DebugDataProvider.php in Depicter — Popup & Slider Builder 1.6.2, at vendor/htmlburger/wpemerge/src/Exceptions/Whoops/DebugDataProvider.php

75 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPEmerge\Exceptions\Whoops;
4
5 use Pimple\Container;
6
7 /**
8 * Provide debug data for usage with \Whoops\Handler\PrettyPageHandler.
9 *
10 * @codeCoverageIgnore
11 */
12 class DebugDataProvider {
13 /**
14 * Container.
15 *
16 * @var Container
17 */
18 protected $container = null;
19
20 /**
21 * Constructor.
22 *
23 * @param Container $container
24 */
25 public function __construct( $container ) {
26 $this->container = $container;
27 }
28
29 /**
30 * Convert a value to a scalar representation.
31 *
32 * @param mixed $value
33 * @return mixed
34 */
35 public function toScalar( $value ) {
36 $type = gettype( $value );
37
38 if ( ! is_scalar( $value ) ) {
39 $value = '(' . $type . ')' . ( $type === 'object' ? ' ' . get_class( $value ) : '' );
40 }
41
42 return $value;
43 }
44
45 /**
46 * Return printable data about the current route.
47 *
48 * @param \Whoops\Exception\Inspector $inspector
49 * @return array<string, mixed>
50 */
51 public function route( $inspector ) {
52 /** @var \WPEmerge\Routing\RouteInterface|null $route */
53 $route = $this->container[ WPEMERGE_ROUTING_ROUTER_KEY ]->getCurrentRoute();
54
55 if ( ! $route ) {
56 return [];
57 }
58
59 $attributes = [];
60
61 foreach ( $route->getAttributes() as $attribute => $value ) {
62 // Only convert the first level of an array to scalar for simplicity.
63 if ( is_array( $value ) ) {
64 $value = '[' . implode( ', ', array_map( [$this, 'toScalar'], $value ) ) . ']';
65 } else {
66 $value = $this->toScalar( $value );
67 }
68
69 $attributes[ $attribute ] = $value;
70 }
71
72 return $attributes;
73 }
74 }
75