Skip to content

Commit

Permalink
refactor: remove $lineSeparator and replace explode with preg_split
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukáš Melega committed May 23, 2024
1 parent 6f9fd5c commit a928549
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions xExtension-WordHighlighter/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ public function handleConfigureAction(): void
$this->case_sensitive = (bool) Minz_Request::paramString('case_sensitive');
$this->separate_word_search = (bool) Minz_Request::paramString('separate_word_search');

$lineSeparator = ((bool) strpos($configWordList, "\r\n")) ? "\r\n" : "\n";
$configObj = [
'enable_in_article' => $this->enable_in_article,
'enable_logs' => $this->enable_logs,
'case_sensitive' => $this->case_sensitive,
'separate_word_search' => $this->separate_word_search,
'words' => explode($lineSeparator, $configWordList),
'words' => preg_split("/\r\n|\n|\r/", $configWordList),
];
$configJson = json_encode($configObj, WordHighlighterExtension::JSON_ENCODE_CONF);
file_put_contents(join_path($staticPath, ('config.' . $current_user . '.json')), $configJson . PHP_EOL);
Expand Down

0 comments on commit a928549

Please sign in to comment.