PluginProbe
ManageWP Worker / 4.9.25
ManageWP Worker v4.9.25
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / src / MWP / IncrementalBackup / Model / ServerStatistics.php

ServerStatistics.php in ManageWP Worker 4.9.25, at src/MWP/IncrementalBackup/Model/ServerStatistics.php

118 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * This file is part of the ManageWP Worker plugin.
4 *
5 * (c) ManageWP LLC <contact@managewp.com>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10
11 class MWP_IncrementalBackup_Model_ServerStatistics
12 {
13
14 /** @var int */
15 private $memoryPeak;
16
17 /** @var int */
18 private $memoryUsage;
19
20 /** @var int */
21 private $averageLoad;
22
23 /** @var bool */
24 private $shellAvailable;
25
26 function __construct($memoryPeak, $memoryUsage, $averageLoad, $shellAvailable)
27 {
28 $this->memoryPeak = $memoryPeak;
29 $this->memoryUsage = $memoryUsage;
30 $this->averageLoad = $averageLoad;
31 $this->shellAvailable = $shellAvailable;
32 }
33
34 /**
35 * @return int
36 */
37 public function getMemoryPeak()
38 {
39 return $this->memoryPeak;
40 }
41
42 /**
43 * @param int $memoryPeak
44 */
45 public function setMemoryPeak($memoryPeak)
46 {
47 $this->memoryPeak = $memoryPeak;
48 }
49
50 /**
51 * @return int
52 */
53 public function getMemoryUsage()
54 {
55 return $this->memoryUsage;
56 }
57
58 /**
59 * @param int $memoryUsage
60 */
61 public function setMemoryUsage($memoryUsage)
62 {
63 $this->memoryUsage = $memoryUsage;
64 }
65
66 /**
67 * @return int
68 */
69 public function getAverageLoad()
70 {
71 return $this->averageLoad;
72 }
73
74 /**
75 * @param int $averageLoad
76 */
77 public function setAverageLoad($averageLoad)
78 {
79 $this->averageLoad = $averageLoad;
80 }
81
82 /**
83 * @return boolean
84 */
85 public function isShellAvailable()
86 {
87 return $this->shellAvailable;
88 }
89
90 /**
91 * @param boolean $shellAvailable
92 */
93 public function setShellAvailable($shellAvailable)
94 {
95 $this->shellAvailable = $shellAvailable;
96 }
97
98 public function toArray()
99 {
100 return array(
101 'memory_peak' => $this->getMemoryPeak(),
102 'memory_usage' => $this->getMemoryUsage(),
103 'average_load' => $this->getAverageLoad(),
104 'shell_available' => $this->isShellAvailable(),
105 );
106 }
107
108 public static function factory()
109 {
110 return new self(
111 memory_get_peak_usage(true),
112 memory_get_usage(true),
113 function_exists('sys_getloadavg') ? sys_getloadavg() : array(0, 0, 0),
114 mwp_is_shell_available()
115 );
116 }
117 }
118