Skip to content

Commit

Permalink
Merge pull request #13 from faissaloux/rename-Investigator-methods
Browse files Browse the repository at this point in the history
Rename Investigator methods
  • Loading branch information
faissaloux authored Oct 26, 2024
2 parents a17eb22 + 2e3ae36 commit 0874ebd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Expectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function toReturnLowercase(int $depth = -1): void
{
$this->applyOnDirectory(
$depth,
fn (array $content): array => $this->lowercasesIn($content),
fn (array $content): array => $this->notLowercasesIn($content),
'Not lowercase detected'
);
}
Expand All @@ -30,7 +30,7 @@ public function toReturnSingleWords(int $depth = -1): void
{
$this->applyOnDirectory(
$depth,
fn (array $content): array => $this->singleWordsIn($content),
fn (array $content): array => $this->multipleWordsIn($content),
'Not single words detected'
);
}
Expand Down
11 changes: 7 additions & 4 deletions src/Investigator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

namespace Faissaloux\PestInside;

/**
* @internal
*/
trait Investigator
{
/**
* @param array<string|array<string>> $array
* @return array<string>
*/
private function lowercasesIn(array $array): array
private function notLowercasesIn(array $array): array
{
$unwanted = [];

Expand All @@ -20,7 +23,7 @@ private function lowercasesIn(array $array): array
}

if (is_array($word)) {
array_push($unwanted, ...$this->lowercasesIn($word));
array_push($unwanted, ...$this->notLowercasesIn($word));

continue;
}
Expand Down Expand Up @@ -63,13 +66,13 @@ private function duplicatesIn(array $array): array
* @param array<string|array<string>> $array
* @return array<string>
*/
private function singleWordsIn(array $array): array
private function multipleWordsIn(array $array): array
{
$unwanted = [];

foreach ($array as $word) {
if (is_array($word)) {
array_push($unwanted, ...$this->singleWordsIn($word));
array_push($unwanted, ...$this->multipleWordsIn($word));

continue;
}
Expand Down

0 comments on commit 0874ebd

Please sign in to comment.