-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Investigator and refactor Expectation
- Loading branch information
1 parent
e2de4b4
commit 8ca0807
Showing
7 changed files
with
78 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Faissaloux\PestInside; | ||
|
||
trait Investigator | ||
{ | ||
/** | ||
* @param array<string> $array | ||
* | ||
* @return array<string> | ||
*/ | ||
private function lowercasesIn(array $array): array | ||
{ | ||
$notLowerCase = []; | ||
|
||
foreach ($array as $word) { | ||
if ($word === '') { | ||
continue; | ||
} | ||
|
||
if (! ctype_lower(preg_replace('/[^A-Za-z]/', '', $word))) { | ||
array_push($notLowerCase, $word); | ||
} | ||
} | ||
|
||
return $notLowerCase; | ||
} | ||
|
||
/** | ||
* @param array<string> $array | ||
* | ||
* @return array<string> | ||
*/ | ||
private function duplicatesIn(array $array): array | ||
{ | ||
return array_diff_assoc($array, array_unique($array)); | ||
} | ||
|
||
/** | ||
* @param array<string> $array | ||
* | ||
* @return array<string> | ||
*/ | ||
private function singleWordsIn(array $array): array | ||
{ | ||
return array_filter($array, fn (string $word): bool => str_contains(trim($word), ' ')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ | |
'lowercase', | ||
'loWer', | ||
'case', | ||
'nOt', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters