webignition/disallowed-character-terminated-string
Str helper but offers niche functionality (e.g., multi-character termination) not covered by built-in methods. Useful in:
substr()/explode() logic with a reusable component.TerminatedString class is lightweight and encapsulates logic without imposing architectural constraints, making it suitable for both one-off tasks and reusable utilities.Str helpers).@phpstan/phpstan or fork the package.\n in UTF-8 strings).
mb_strpos() alternatives if needed.phpunit/phpunit).composer.json; monitor for vulnerabilities via composer audit.Why Not Laravel’s Str Helper?
Str::of()->beforeLast() or substr()? If so, what specific use cases justify its adoption?['#', '--']) or custom delimiter logic.PHP Version Strategy
Error Handling in Laravel Context
null conventions.Testing Scope
Long-Term Ownership
Alternatives Assessment
league/string-data, symfony/string) with better maintenance records?Laravel-Specific Integrations:
TerminatedString for dependency injection:
$this->app->bind(TerminatedString::class, function () {
return new TerminatedString($input, $terminators);
});
Str::terminated()):
use Illuminate\Support\Facades\Str;
Str::terminated('value #comment', ['#']); // Returns 'value '
use Illuminate\Validation\Rule;
Rule::make(function ($attribute, $value, $parameters) {
$terminated = new TerminatedString($value, $parameters['terminators']);
return strlen($terminated->get()) <= $parameters['max_length'];
});
Use Case Examples:
Proof of Concept (PoC):
composer require webignition/disallowed-character-terminated-string --dev
substr, explode) for performance parity.Phased Adoption:
substr($str, 0, strpos($str, '#'))).app/Helpers/StringHelper.php).Dependency Management:
composer.json to avoid updates:
"require": {
"webignition/disallowed-character-terminated-string": "^1.0"
}
composer audit
array() syntax).@phpstan/phpstan, php -l (linting).mb_* functions).\n, \r, or non-ASCII terminators.mb_strpos() if issues arise.composer.json and run composer install.phpunit/phpunit).composer audit).Str helpers.var_dump($string->get())).How can I help you explore Laravel packages today?