$state_statuses) { // Ternary-depth systemd type check. if (! preg_match('/^(.+)_(.+)$/', $flattened_type, $regex_matches)) { continue; } if ($regex_matches[1] !== $state_type) { continue; } $graph_descr = ucfirst($flattened_type) . ' State'; $graphs[$graph_name]['sub_states'][$flattened_type][ 'desc' ] = $graph_descr; } } return $graphs; } /** * Builds a graph array and outputs the graph. * * @param string $state_type * @param string $app_id * @param null|string $sub_state_type * @param string $graph_desc */ function systemd_graph_printer( $state_type, $app_id, $sub_state_type, $graph_desc ) { $graph_type = $state_type; $graph_array['height'] = '100'; $graph_array['width'] = '215'; $graph_array['to'] = time(); $graph_array['id'] = $app_id; $graph_array['type'] = 'application_' . $state_type; if (! is_null($sub_state_type)) { $graph_array['sub_state_type'] = $sub_state_type; } echo '