Each entry of * active_plugins and of the keys of active_sitewide_plugins; option is the option * name; exists = the file is present under the plugins folder. * * @package Timaub\AfterHackChecklist */ namespace Timaub\AfterHackChecklist\Domain; final class SettingsSnapshot { /** @var string */ public $siteurl = ''; /** @var string */ public $home = ''; /** @var string|null */ public $wpHome; /** @var string|null */ public $wpSiteurl; /** @var bool */ public $usersCanRegister = false; /** @var string */ public $defaultRole = ''; /** @var array */ public $activePlugins = array(); public static function fromArray( array $a ): self { $s = new self(); $s->siteurl = isset( $a['siteurl'] ) ? (string) $a['siteurl'] : ''; $s->home = isset( $a['home'] ) ? (string) $a['home'] : ''; $s->wpHome = isset( $a['wpHome'] ) ? (string) $a['wpHome'] : null; $s->wpSiteurl = isset( $a['wpSiteurl'] ) ? (string) $a['wpSiteurl'] : null; $s->usersCanRegister = ! empty( $a['usersCanRegister'] ); $s->defaultRole = isset( $a['defaultRole'] ) ? (string) $a['defaultRole'] : ''; foreach ( isset( $a['activePlugins'] ) ? (array) $a['activePlugins'] : array() as $p ) { $s->activePlugins[] = array( 'entry' => (string) $p['entry'], 'option' => isset( $p['option'] ) ? (string) $p['option'] : 'active_plugins', 'exists' => ! empty( $p['exists'] ), ); } return $s; } public function toArray(): array { return get_object_vars( $this ); } }