Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
helperfunctions
codebar-ag/coding-guidelines
architect
implement
refactor
review
helpers
collections
str
arr
refactoring
fluent-chains

Always prefer Laravel's built-in helper classes over native PHP functions. Use `Arr::`, `Str::`, and Collection methods instead of native PHP equivalents.

Install
php artisan boost:add-skill codebar-ag/coding-guidelines

Save this content to: .claude/skills/helperfunctions/SKILL.md

# Helper Functions

## When to Apply

- When transforming arrays, strings, or iterables in Laravel application code.
- When refactoring native PHP utility code to improve readability and consistency.
- When chaining multiple transformations on text or data collections.

## When NOT to Apply

- When no Laravel equivalent exists and native PHP is clearer.
- In tight low-level loops where collection wrapping would add unnecessary overhead.
- In framework-agnostic packages that should not depend on Laravel helpers.

## Preconditions

- Import `Illuminate\Support\Arr` for array helpers.
- Import `Illuminate\Support\Str` for string helpers.
- Use `collect()` only when collection operations improve clarity.

## Process

1. Identify native PHP helper usage (`array_*`, `str_*`, manual loops).
2. Replace with `Arr::`, `Str::`, or Collection methods where a direct equivalent exists.
3. Keep behavior identical (defaults, key handling, casing, null handling).
4. Prefer fluent chains (`Str::of()`, collections) for multi-step transformations.
5. Re-run tests/static analysis for the touched scope.

## Examples

```php
use Illuminate\Support\Arr;
use Illuminate\Support\Str;

// Arrays
$city = Arr::get($payload, 'user.address.city', 'Unknown');
$safe = Arr::except($payload, ['password', 'token']);

// Strings
$slug = Str::of($title)->trim()->lower()->slug();

// Collections
$adminEmails = collect($users)
    ->filter(fn (User $user) => $user->isAdmin())
    ->pluck('email')
    ->values();
```

## Anti-Patterns

- Mixing native `array_*`/`str_*` calls with Laravel helpers in the same transformation flow.
- Replacing simple one-liners with collection chains that reduce readability.
- Omitting `use` imports and relying on fully qualified class names repeatedly.
- Rewriting code when no Laravel helper exists and native PHP is already explicit.

## References

- [Laravel Arr Helper](https://laravel.com/docs/helpers#arrays)
- [Laravel Str Helper](https://laravel.com/docs/helpers#strings)
- [Laravel Collections](https://laravel.com/docs/collections)

Helper Functions

When to Apply

  • When transforming arrays, strings, or iterables in Laravel application code.
  • When refactoring native PHP utility code to improve readability and consistency.
  • When chaining multiple transformations on text or data collections.

When NOT to Apply

  • When no Laravel equivalent exists and native PHP is clearer.
  • In tight low-level loops where collection wrapping would add unnecessary overhead.
  • In framework-agnostic packages that should not depend on Laravel helpers.

Preconditions

  • Import Illuminate\Support\Arr for array helpers.
  • Import Illuminate\Support\Str for string helpers.
  • Use collect() only when collection operations improve clarity.

Process

  1. Identify native PHP helper usage (array_*, str_*, manual loops).
  2. Replace with Arr::, Str::, or Collection methods where a direct equivalent exists.
  3. Keep behavior identical (defaults, key handling, casing, null handling).
  4. Prefer fluent chains (Str::of(), collections) for multi-step transformations.
  5. Re-run tests/static analysis for the touched scope.

Examples

use Illuminate\Support\Arr;
use Illuminate\Support\Str;

// Arrays
$city = Arr::get($payload, 'user.address.city', 'Unknown');
$safe = Arr::except($payload, ['password', 'token']);

// Strings
$slug = Str::of($title)->trim()->lower()->slug();

// Collections
$adminEmails = collect($users)
    ->filter(fn (User $user) => $user->isAdmin())
    ->pluck('email')
    ->values();

Anti-Patterns

  • Mixing native array_*/str_* calls with Laravel helpers in the same transformation flow.
  • Replacing simple one-liners with collection chains that reduce readability.
  • Omitting use imports and relying on fully qualified class names repeatedly.
  • Rewriting code when no Laravel helper exists and native PHP is already explicit.

References

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource