← All changes
|
jetpack_vendor/automattic/jetpack-protect-models/src/class-status-model.php
+174
-0
16.2-beta
→
16.3-beta
View file →
| @@ -1,0 +1,174 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * Model class for Protect status report data. | |
| 4 | + * | |
| 5 | + * @package automattic/jetpack-protect-models | |
| 6 | + */ | |
| 7 | + | |
| 8 | +namespace Automattic\Jetpack\Protect_Models; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * Model class for the Protect status report data. | |
| 12 | + */ | |
| 13 | +class Status_Model { | |
| 14 | + /** | |
| 15 | + * Data source. | |
| 16 | + * | |
| 17 | + * @var string protect_report|scan_api | |
| 18 | + */ | |
| 19 | + public $data_source; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * The date and time when the status was generated. | |
| 23 | + * | |
| 24 | + * @var string | |
| 25 | + */ | |
| 26 | + public $last_checked; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * The current report status. | |
| 30 | + * | |
| 31 | + * @var string in_progress|scheduled|idle|scanning|provisioning|unavailable | |
| 32 | + */ | |
| 33 | + public $status; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * The current reported security threats. | |
| 37 | + * | |
| 38 | + * @since 0.4.0 | |
| 39 | + * | |
| 40 | + * @var array<Threat_Model> | |
| 41 | + */ | |
| 42 | + public $threats = array(); | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * List of fixable threat IDs. | |
| 46 | + * | |
| 47 | + * @var string[] | |
| 48 | + */ | |
| 49 | + public $fixable_threat_ids = array(); | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * Whether the site includes items that have not been checked. | |
| 53 | + * | |
| 54 | + * @var boolean | |
| 55 | + */ | |
| 56 | + public $has_unchecked_items; | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * The estimated percentage of the current scan. | |
| 60 | + * | |
| 61 | + * @var int | |
| 62 | + */ | |
| 63 | + public $current_progress; | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * Whether there was an error loading the status. | |
| 67 | + * | |
| 68 | + * @var bool | |
| 69 | + */ | |
| 70 | + public $error = false; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * The error code thrown when loading the status. | |
| 74 | + * | |
| 75 | + * @var string | |
| 76 | + */ | |
| 77 | + public $error_code; | |
| 78 | + | |
| 79 | + /** | |
| 80 | + * The error message thrown when loading the status. | |
| 81 | + * | |
| 82 | + * @var string | |
| 83 | + */ | |
| 84 | + public $error_message; | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * The number of threats. | |
| 88 | + * | |
| 89 | + * @deprecated 0.4.0 This property is deprecated. Count Status_Model::$threats instead. | |
| 90 | + * | |
| 91 | + * @var int | |
| 92 | + */ | |
| 93 | + public $num_threats; | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * The number of plugin threats. | |
| 97 | + * | |
| 98 | + * @deprecated 0.4.0 This property is deprecated. Filter and count Status_Model::$threats instead. | |
| 99 | + * | |
| 100 | + * @var int | |
| 101 | + */ | |
| 102 | + public $num_plugins_threats; | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * The number of theme threats. | |
| 106 | + * | |
| 107 | + * @deprecated 0.4.0 This property is deprecated. Filter and count Status_Model::$threats instead. | |
| 108 | + * | |
| 109 | + * @var int | |
| 110 | + */ | |
| 111 | + public $num_themes_threats; | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * WordPress core status. | |
| 115 | + * | |
| 116 | + * @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead. | |
| 117 | + * | |
| 118 | + * @var object | |
| 119 | + */ | |
| 120 | + public $core; | |
| 121 | + | |
| 122 | + /** | |
| 123 | + * Status themes. | |
| 124 | + * | |
| 125 | + * @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead. | |
| 126 | + * | |
| 127 | + * @var array<Extension_Model> | |
| 128 | + */ | |
| 129 | + public $themes = array(); | |
| 130 | + | |
| 131 | + /** | |
| 132 | + * Status plugins. | |
| 133 | + * | |
| 134 | + * @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead. | |
| 135 | + * | |
| 136 | + * @var array<Extension_Model> | |
| 137 | + */ | |
| 138 | + public $plugins = array(); | |
| 139 | + | |
| 140 | + /** | |
| 141 | + * File threats. | |
| 142 | + * | |
| 143 | + * @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead. | |
| 144 | + * | |
| 145 | + * @var array<Extension_Model> | |
| 146 | + */ | |
| 147 | + public $files = array(); | |
| 148 | + | |
| 149 | + /** | |
| 150 | + * Database threats. | |
| 151 | + * | |
| 152 | + * @deprecated 0.4.0 This property is deprecated. Filter and use Status_Model::$threats instead. | |
| 153 | + * | |
| 154 | + * @var array<Extension_Model> | |
| 155 | + */ | |
| 156 | + public $database = array(); | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * Status constructor. | |
| 160 | + * | |
| 161 | + * @param array $status The status data to load into the class instance. | |
| 162 | + */ | |
| 163 | + public function __construct( $status = array() ) { | |
| 164 | + // set status defaults | |
| 165 | + // @phan-suppress-next-line PhanDeprecatedProperty -- Maintaining backwards compatibility. | |
| 166 | + $this->core = new \stdClass(); | |
| 167 | + | |
| 168 | + foreach ( $status as $property => $value ) { | |
| 169 | + if ( property_exists( $this, $property ) ) { | |
| 170 | + $this->$property = $value; | |
| 171 | + } | |
| 172 | + } | |
| 173 | + } | |
| 174 | +} | |