PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.9.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.9.0
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Preload / Limiter / Load / Load.php

Load.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.9.0, at src/Performance/Preload/Limiter/Load/Load.php

102 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Current System Load Average DTO.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Preload\Limiter\Load;
11
12 /**
13 * The Current System Load Average DTO.
14 *
15 * @package SolidWP\Performance
16 */
17 final class Load {
18
19 /**
20 * The one-minute load average.
21 *
22 * @var float
23 */
24 private float $one_min;
25
26 /**
27 * The five-minute load average.
28 *
29 * @var float
30 */
31 private float $five_min;
32
33 /**
34 * The fifteen-minute load average.
35 *
36 * @var float
37 */
38 private float $fifteen_min;
39
40 /**
41 * Create a new load instance.
42 *
43 * @param float[] $load The system load averages.
44 *
45 * @return self
46 */
47 public static function from( array $load ): self {
48 return new self( ...$load );
49 }
50
51 /**
52 * @param float $one_min The one-minute load average.
53 * @param float $five_min The five-minute load average.
54 * @param float $fifteen_min The fifteen-minute load average.
55 */
56 private function __construct( float $one_min, float $five_min, float $fifteen_min ) {
57 $this->one_min = $one_min;
58 $this->five_min = $five_min;
59 $this->fifteen_min = $fifteen_min;
60 }
61
62 /**
63 * Get all the system load averages.
64 *
65 * @return array<string, float>
66 */
67 public function all(): array {
68 return [
69 '1' => $this->one_min,
70 '5' => $this->five_min,
71 '15' => $this->fifteen_min,
72 ];
73 }
74
75 /**
76 * Get the one-minute load average.
77 *
78 * @return float
79 */
80 public function one_min(): float {
81 return $this->one_min;
82 }
83
84 /**
85 * Get the five-minute load average.
86 *
87 * @return float
88 */
89 public function five_min(): float {
90 return $this->five_min;
91 }
92
93 /**
94 * Get the fifteen-minute load average.
95 *
96 * @return float
97 */
98 public function fifteen_min(): float {
99 return $this->fifteen_min;
100 }
101 }
102