PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / modules / mcp / abilities / utils / tool-performance-metrics.php

tool-performance-metrics.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/mcp/abilities/utils/tool-performance-metrics.php

39 lines 812 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Mcp\Abilities\Utils;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 class Tool_Performance_Metrics {
10
11 public static function duration_ms_since( int $started_at ): int {
12 return (int) round( ( hrtime( true ) - $started_at ) / 1_000_000 );
13 }
14
15 public static function resolve_status( array $response, ?\WP_Error $top_level_error ): array {
16 if ( null !== $top_level_error ) {
17 return [
18 'status' => 'error',
19 'error_code' => $top_level_error->get_error_code(),
20 ];
21 }
22
23 $batch_status = $response['status'] ?? 'error';
24
25 if ( 'ok' === $batch_status ) {
26 $status = 'success';
27 } elseif ( 'partial_error' === $batch_status ) {
28 $status = 'partial';
29 } else {
30 $status = 'error';
31 }
32
33 return [
34 'status' => $status,
35 'error_code' => null,
36 ];
37 }
38 }
39