Download the PHP package divengine/laze without Composer
On this page you can find all versions of the php package divengine/laze. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download divengine/laze
More information about divengine/laze
Files in divengine/laze
Package laze
Short Description Div PHP Laze
License GPL-3.0-or-later
Homepage https://divengine.org
Informations about the package laze
Div PHP Laze
laze is a PHP library designed for defining lazy evaluation. Values are set as closures and only materialize upon first access, ensuring efficient and controlled initialization. Once a closure function is evaluated, it becomes immutable and cannot be redefined as a different value. However, it can be redefined as a closure until it’s accessed, at which point it transforms into a non-closure value.
Laze provides lazy immutable values for PHP. You define a key with a closure, and the value is computed on first read and then cached.
Requirements
- PHP 8.0 or higher
Installation
Quick start
Core API
laze::define($key, $callable)registers a lazy value.laze::read($key)evaluates once and returns the stored value.laze::defined($key)checks if a key exists.laze::evaluated($key)checks if a key was evaluated (throws if undefined).laze::constraint($name, $checker)validates values on evaluation.
Redefinition rules
You can redefine a value before it is evaluated. After the first read, the
value becomes immutable and further define calls are ignored.
Constraints
Constraints run when a value is evaluated. If a constraint returns false,
read throws an exception.
Testing tips
Laze stores state statically. You can reset it between tests with reflection:
Or run PHPUnit with process isolation:
Docs
See docs/README.md for guides and FAQ.
License
This project is licensed under the GNU General Public License. See LICENSE.
Contributing
Contributions are welcome. Please open an issue or submit a pull request.
About
Laze is developed and maintained by Divengine Software Solutions.