-
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.
- Loading branch information
1 parent
95586d3
commit a5434e2
Showing
3 changed files
with
56 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Helpers\Http; | ||
|
||
final readonly class RequestHelper | ||
{ | ||
public static function toBoolean(mixed $possibleBoolean): ?bool | ||
{ | ||
return filter_var($possibleBoolean, FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE); | ||
} | ||
|
||
/** | ||
* @return array<string> | ||
*/ | ||
public static function parseStringIntoArray(string $inputString): array | ||
{ | ||
return array_filter( | ||
array_map('trim', explode(',', $inputString)), | ||
static fn ($item) => $item !== '' | ||
); | ||
} | ||
|
||
/** | ||
* @return array<int> | ||
*/ | ||
public static function parseStringIntoIntArray(string $inputString): array | ||
{ | ||
return array_map( | ||
'intval', | ||
array_filter( | ||
self::parseStringIntoArray($inputString), | ||
static fn ($item) => is_numeric($item) | ||
) | ||
); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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