Skip to content

Commit

Permalink
remove unused public method on interface
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Dec 27, 2024
1 parent 00a1f72 commit 966f24e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
10 changes: 6 additions & 4 deletions peck.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"whitelistedWords": [
"config"
],
"whitelistedDirectories": []
"ignore": {
"words": [
"config"
],
"directories": []
}
}
11 changes: 8 additions & 3 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ public static function instance(): self

$contents = (string) file_get_contents($basePath.'/peck.json');

/** @var array{whitelistedWords?: array<int, string>, whitelistedDirectories?: array<int, string>} $jsonAsArray */
/** @var array{
* ignore?: array{
* words?: array<int, string>,
* directories?: array<int, string>
* }
* } $jsonAsArray */
$jsonAsArray = json_decode($contents, true) ?: [];

return self::$instance = new self(
$jsonAsArray['whitelistedWords'] ?? [],
$jsonAsArray['whitelistedDirectories'] ?? [],
$jsonAsArray['ignore']['words'] ?? [],
$jsonAsArray['ignore']['directories'] ?? [],
);
}
}
8 changes: 0 additions & 8 deletions src/Contracts/Services/Spellchecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,4 @@ interface Spellchecker
* @return array<int, Misspelling>
*/
public function check(string $text): array;

/**
* Filters the given words against the whitelisted words stored in the configuration.
*
* @param array<int, \PhpSpellcheck\MisspellingInterface> $misspellings
* @return array<int, \PhpSpellcheck\MisspellingInterface> $misspellings
*/
public function filterWhitelistedWords(array $misspellings): array;
}
2 changes: 1 addition & 1 deletion src/Services/Spellcheckers/InMemorySpellchecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function check(string $text): array
* @param array<int, \PhpSpellcheck\MisspellingInterface> $misspellings
* @return array<int, \PhpSpellcheck\MisspellingInterface> $misspellings
*/
public function filterWhitelistedWords(array $misspellings): array
private function filterWhitelistedWords(array $misspellings): array
{
return array_filter($misspellings, fn (MisspellingInterface $misspelling): bool => ! in_array(
strtolower($misspelling->getWord()),
Expand Down

0 comments on commit 966f24e

Please sign in to comment.