From 2c935ac1de6692becb5e26ec0feecad8f48f0c53 Mon Sep 17 00:00:00 2001 From: Igor Hrcek Date: Mon, 21 Mar 2022 12:23:08 +0100 Subject: [PATCH] feat: Code refactoring --- src/SubCommands/BlockAccessToSensitiveDirectories.php | 2 +- src/SubCommands/BlockAccessToSensitiveFiles.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/SubCommands/BlockAccessToSensitiveDirectories.php b/src/SubCommands/BlockAccessToSensitiveDirectories.php index 09bf546..7e9aa85 100644 --- a/src/SubCommands/BlockAccessToSensitiveDirectories.php +++ b/src/SubCommands/BlockAccessToSensitiveDirectories.php @@ -16,7 +16,7 @@ class BlockAccessToSensitiveDirectories extends SubCommand { /** * @return array */ - public function getTemplateVars() { + public function getTemplateVars() : array { $directories = $this->commandArguments['directories'] ?? $this->sensitiveDirectories; if ( ! empty( $directories ) ) { $directories = explode( ',', $directories ); diff --git a/src/SubCommands/BlockAccessToSensitiveFiles.php b/src/SubCommands/BlockAccessToSensitiveFiles.php index f153ed4..0a9b2c4 100644 --- a/src/SubCommands/BlockAccessToSensitiveFiles.php +++ b/src/SubCommands/BlockAccessToSensitiveFiles.php @@ -8,8 +8,13 @@ class BlockAccessToSensitiveFiles extends SubCommand { public string $successMessage = 'Block Access to Sensitive Files rule has been deployed.'; public string $removalMessage= 'Block Access to Sensitive Files rule has been removed.'; - public function getTemplateVars() { - $files = isset( $this->commandArguments['files'] ) ? $this->commandArguments['files'] : 'readme.html,readme.txt,wp-config.php,nginx.conf,/wp-admin/install.php,/wp-admin/upgrade.php'; + /** + * @var string List of files that we are protecting by default + */ + private string $protectedFiles = 'readme.html,readme.txt,wp-config.php,nginx.conf,/wp-admin/install.php,/wp-admin/upgrade.php'; + + public function getTemplateVars() : array { + $files = $this->commandArguments['files'] ?? $this->protectedFiles; if ( ! empty( $files ) ) { $files = explode( ',', $files ); $files = array_map( 'trim', $files );