Skip to content

Commit

Permalink
add request helper
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-oleksyuk committed Dec 14, 2024
1 parent 95586d3 commit a5434e2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 18 deletions.
38 changes: 38 additions & 0 deletions app/Helpers/Http/RequestHelper.php
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)
)
);
}
}
28 changes: 14 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions config/utils/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
])
->withPhpVersion(PhpVersion::PHP_83)
->withSets([
// LaravelLevelSetList::UP_TO_LARAVEL_110,
LaravelLevelSetList::UP_TO_LARAVEL_110,
LaravelSetList::LARAVEL_110,
// LaravelSetList::LARAVEL_ARRAYACCESS_TO_METHOD_CALL,
LaravelSetList::LARAVEL_ARRAYACCESS_TO_METHOD_CALL,
LaravelSetList::LARAVEL_ARRAY_STR_FUNCTION_TO_STATIC_CALL,
// LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_CODE_QUALITY,
LaravelSetList::LARAVEL_COLLECTION,
LaravelSetList::LARAVEL_CONTAINER_STRING_TO_FULLY_QUALIFIED_NAME,
LaravelSetList::LARAVEL_ELOQUENT_MAGIC_METHOD_TO_QUERY_BUILDER,
LaravelSetList::LARAVEL_FACADE_ALIASES_TO_FULL_NAMES,
// LaravelSetList::LARAVEL_IF_HELPERS,
LaravelSetList::LARAVEL_IF_HELPERS,
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
LaravelSetList::LARAVEL_STATIC_TO_INJECTION,
])
Expand Down

0 comments on commit a5434e2

Please sign in to comment.