azjezz/psl
PSL (PHP Standard Library) offers a consistent, well-typed set of safer, async-ready APIs to replace PHP primitives. Covers async, collections, networking, I/O, cryptography, terminal UI, and type-safe data validation with predictable errors.
The Default component introduces a uniform approach for classes within PSL to provide and utilize default instances.
It encapsulates the DefaultInterface, establishing a contract that enables implementing classes to offer a standardized method for instantiating themselves with default values or settings. This pattern is beneficial when an object needs sensible defaults but also allows customization through further configuration.
@example('types/default-enum.php')
Classes and enums that implement DefaultInterface provide a static default() method returning a new instance initialized with default values:
@example('types/default-class.php')
Implementing DefaultInterface signals that a class supports this standardized mechanism for obtaining default instances, ensuring consistency across PSL.
See src/Psl/Default/ for the full API.
How can I help you explore Laravel packages today?