Skip to content

Commit

Permalink
feat: Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
igorhrcek committed Mar 21, 2022
1 parent 35ab6a1 commit 2c935ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/SubCommands/BlockAccessToSensitiveDirectories.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
9 changes: 7 additions & 2 deletions src/SubCommands/BlockAccessToSensitiveFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 2c935ac

Please sign in to comment.