Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic type to the Str utility methods #62

Merged
merged 6 commits into from
Oct 14, 2024
Merged

Conversation

tfirdaus
Copy link
Member

@tfirdaus tfirdaus commented Oct 9, 2024

Generic will allow the method to infer the type returned based on the argument type. For example:

/** @var array<string,string> $arr */
$arr = ['foo' => ''];
$val = Str::toSnakeCase($arr); // Type: string.

/** @var array<string,non-empty-string> $arr */
$arr = ['foo' => 'bar_123'];
$val = Str::toSnakeCase($arr); // Type: non-empty-string.

@tfirdaus tfirdaus added enhancement A new feature or request. php Related to PHP codebase. labels Oct 9, 2024
Copy link

codecov bot commented Oct 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.40%. Comparing base (8c28930) to head (d8d94a5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main      #62      +/-   ##
============================================
+ Coverage     91.33%   99.40%   +8.06%     
  Complexity       69       69              
============================================
  Files             4        4              
  Lines           127      167      +40     
============================================
+ Hits            116      166      +50     
+ Misses           11        1      -10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tfirdaus tfirdaus marked this pull request as ready for review October 14, 2024 17:46
@tfirdaus tfirdaus merged commit c206e08 into main Oct 14, 2024
8 checks passed
@tfirdaus tfirdaus deleted the feat/str-generics branch October 14, 2024 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or request. php Related to PHP codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant