Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 | } |
||
75 |