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

Trimmed Non Empty String Laravel Package

oskarstark/trimmed-non-empty-string

A tiny PHP value object that trims surrounding whitespace from strings and guarantees the result is non-empty, throwing an exception when validation fails. Use it to keep user input and domain values clean, predictable, and safe.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Assessment of release 1.11.2: This is a tooling-only patch. All four merged PRs are internal engineering hygiene — removal of a CI env flag, adoption of a shared ergebnis/php-cs-fixer-config ruleset, a test assertion style change (assertNotSame), and introduction of Rector with a fluent config builder. There are no public API changes, no behavioral changes, no deprecations, and no new features. Runtime risk from upgrading 1.11.1 → 1.11.2 is effectively zero.

Architecture fit: oskarstark/trimmed-non-empty-string is a framework-agnostic, single-purpose PHP value object library (a PSR-4 Composer package, not a Laravel package — no service provider, no config, no facade). It fits cleanly into a Laravel codebase as a domain primitive: DTOs, form-request-normalized input, console command arguments, queue payload construction, and anywhere the codebase currently does trim($x) === '' checks inline. It does not impose architectural opinions, which means it also does not enforce consistency — value only materializes if the team adopts it as a convention.

Integration feasibility: High. A single composer require with no publish/install step, no container bindings, and no migration. The only meaningful compatibility check is the package's require.php constraint; the 8.2 reference in the changelog applies to the upstream dev ruleset and should not be read as a raised runtime floor, but it is worth confirming against composer.json before pinning.

Technical risk: Low on code, moderate on governance. The library is small enough to audit in full in an afternoon, which caps worst-case risk — a fork or vendored copy is a realistic mitigation. The real considerations are bus factor (single primary maintainer, Oskar Stark), a 1.x version line with no stated LTS commitment, and the fact that a package this small delivers modest leverage relative to the supply-chain entry it adds.

Key questions:

  • What is the declared php constraint, and does it match the oldest runtime in our fleet?
  • What exception type is thrown on empty/whitespace input, and does it extend a base we can catch centrally?
  • Does it accept Stringable/int-like inputs, or strictly string? This determines how much normalization we own.
  • Is there a documented BC/security policy, and how quickly has the maintainer shipped security patches historically?
  • Do we need a Laravel Cast wrapper, or is manual construction in DTOs sufficient?

Integration Approach

Stack fit: Drop-in for any PHP 8.x Laravel application. Because it is unopinionated, the integration work is entirely ours: decide the boundary (recommendation — Form Requests and DTO constructors in, Eloquent attribute casting optional), and document it so the object does not become a third way of representing strings alongside string and nullable strings.

Migration path: No migration is required by 1.11.2. Adoption is opportunistic rather than a project: introduce the type in new code first, and convert existing ad-hoc trim/empty validation only where tests already cover the behavior. Avoid a sweeping refactor — the value is in consistency, and a half-migrated codebase delivers none.

Compatibility: SemVer 1.x is being respected; 1.11.2 is a patch with no autoload or signature changes. Pin as ^1.11 and let Composer float patches — the CI churn visible here (PHP-CS-Fixer config consolidation, Rector adoption) is a positive signal that the maintainer keeps the toolchain current, which historically correlates with faster PHP-version compatibility for consumers.

Sequencing: (1) Confirm PHP constraint and read the class source (~1 file). (2) Add the dependency and a single pilot usage behind existing tests. (3) If the pilot holds, add a short internal convention note plus, if warranted, a thin Eloquent cast. (4) Mirror upstream's static-analysis posture — they now run Rector and a shared CS ruleset; ensure our own PHPStan/Rector config does not diverge in ways that make future upgrades noisy. (5) Track upstream releases on a quarterly cadence rather than per-release, since patch releases here are CI-only by nature.

Operational Impact

Maintenance: Negligible runtime maintenance; the changelog indicates the maintenance effort is spent on development tooling. Expect continued low-signal patch releases of this shape. Practical implication: do not treat every 1.11.x as a review event — batch them into routine dependency updates, and reserve real review for minor-version bumps where a new public method might appear.

Support: Community OSS with no SLA and a single primary maintainer. Acceptable for a leaf-node utility; not acceptable if it silently becomes load-bearing across dozens of DTOs without anyone else on the team able to read the implementation. Cheap de-risking: keep the usage surface small and centralized (a factory or cast), so replacing it with an in-house equivalent is a one-file change.

Scaling: Irrelevant as a bottleneck. Immutable value objects, no I/O, no caches, no global state. Allocation cost is within noise compared to framework request overhead. No serialization concerns beyond ensuring the object is reconstructible in queue payloads — if it is not JsonSerializable, jobs must carry the plain string and hydrate on the consumer side.

Failure modes:

  • Unhandled validation exception — the most likely production incident: the constructor throws on empty input, and an uncaught throw during request handling surfaces as a 500 instead of a 422. Mitigate by validating at the Form Request layer and letting the value object be a post-validation invariant.
  • Hydration failure — reading a legacy row or queue payload with an empty/whitespace value and constructing the object directly. Enforce at the boundary, not in the model accessor, or accept that old data can crash reads.
  • Convention drift — the type is adopted in three places and ignored in thirty, giving reviewers a false sense of guaranteed non-emptiness.
  • Supply-chain / abandonment — low severity given code size; fork is trivial.

Ramp-up: Minutes for a developer who has used a value object before. The cost is not learning the API but agreeing on where it belongs in the codebase. Budget a short written convention (one paragraph plus a code example) alongside the dependency, otherwise the package adds a dependency without buying the invariant it exists to provide.

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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin