|Ratings|| ||Unique User Downloads|| ||Download Rankings|
|Not yet rated by the users||Total: 89 ||All time: 9,682 This week: 278|
This class can chain class function calls preventing errors.
It provides a wrapper to a given object so all calls to that object will go through this class in such way can in can queue chained calls to the wrapped object.
The class can all functions of the boxed object that were queued all at once by calling the unbox function of the box object of this class.
Prize: One subscription to the PDF edition of the PHP Architect magazine
|Chaining is an approach used by many developers to make a sequence of calls to the functions of the same object by returning the object again to the next function call, so the developer has to write less code to call all the functions in a sequence.
The problem of this approach is that if one of the function calls fails, it may not return the object, thus breaking the sequence.
This package provides a workaround this problem by wrapping the function calls in a "box" class that can queue the function calls and call one function after another, unless one function fails.
<a href="https://packagist.org/packages/norse-blue/optionals"><img alt="Stable Release" src="https://img.shields.io/packagist/v/norse-blue/optionals.svg?style=flat-square&label=release&logo=packagist&logoColor=eceff4&colorA=4c566a&colorB=5e81ac"></a>
<a href="https://travis-ci.com/norse-blue/php-optionals"><img alt="Build Status" src="https://img.shields.io/travis/com/norse-blue/php-optionals.svg?style=flat-square&label=build&logo=travis-ci&logoColor=eceff4&colorA=4c566a&colorB=88c0d0"></a>
<a href="https://php.net/releases"><img alt="PHP Version" src="https://img.shields.io/packagist/php-v/norse-blue/optionals.svg?style=flat-square&label=php&logo=php&logoColor=eceff4&colorA=4c566a&colorB=b48ead"></a>
<a href="https://codeclimate.com/github/norse-blue/php-optionals"><img alt="Maintainability" src="https://img.shields.io/codeclimate/maintainability/norse-blue/php-optionals.svg?style=flat-square&label=maintainability&logo=code-climate&logoColor=eceff4&colorA=4c566a&colorB=88c0d0"></a>
<a href="https://codeclimate.com/github/norse-blue/php-optionals"><img alt="Test Coverage" src="https://img.shields.io/codeclimate/coverage/norse-blue/php-optionals.svg?style=flat-square&label=coverage&logo=code-climate&logoColor=eceff4&colorA=4c566a&colorB=88c0d0"></a>
<a href="https://packagist.org/packages/norse-blue/optionals"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/norse-blue/optionals.svg?style=flat-square&label=downloads&logoColor=eceff4&colorA=4c566a&colorB=88c0d0"></a>
<a href="https://github.com/norse-blue/php-optionals/blob/master/LICENSE.md"><img alt="License" src="https://img.shields.io/github/license/norse-blue/php-optionals.svg?style=flat-square&label=license&logoColor=eceff4&colorA=4c566a&colorB=a3be8c"></a>
PHP Optionals is a PHP library that allows you to chain method calls or access properties of an object while preventing errors from occurring.
>- PHP 7.3+
Install this package using Composer:
composer require norse-blue/optionals
To get more in-depth knowledge about this package, please refer to the Official Documentation.
Please refer to the CHANGELOG.md file for more information about what has changed recently.
Contributions to this project are accepted and encouraged. Please read the CONTRIBUTING.md file for details on contributions.
Please review our security policy to know how to report security vulnerabilities within this package.
Support the development
Do you like this project? Support it by donating
<a href="https://www.buymeacoffee.com/axelitus"><img src="docs/assets/images/buy-me-a-coffee.svg" width="180" alt="Buy me a coffee"></img></a>
This package is open-sourced software licensed under the MIT license.
||Applications that use this package
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.