Download the PHP package mistralys/application-utils-result-handling without Composer
On this page you can find all versions of the php package mistralys/application-utils-result-handling. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mistralys/application-utils-result-handling
More information about mistralys/application-utils-result-handling
Files in mistralys/application-utils-result-handling
Package application-utils-result-handling
Short Description Classes used to store information on the results of application operations.
License MIT
Informations about the package application-utils-result-handling
AppUtils - Result handling
Collection of classes used to store information on the results of application operations.
This is part of the AppUtils project.
Features
- Store detailed status messages.
- Store success as well as error or warning messages.
- Store a single result or a collection of results.
- Ideal to collect validation messages, for example.
- Recognize results easily with numeric codes.
- Extend the classes to add custom methods.
Requirements
- PHP 7.4 or higher
- Composer
Usage
Single possible result
If an operation can only have a single possible result state,
you can use the OperationResult
class.
NOTE: The
isValid()
method returnstrue
if no state was set, or the state is of the success type.
Collection of results
Introduction
If an operation can have multiple possible result states, like a validation operation, for example, you can use the result collection class.
Every call to makeError()
, makeWarning()
or makeSuccess()
will add a new result instance to the collection.
All result types are stored in the collection, so it is important to note that both failed and successful operations can be tracked.
Quick Start
NOTE: The
isValid()
method returnstrue
if none of the results in the collection are of the error or warning type.
Accessing the results
Accessing results is made to be as easy as possible, with many different ways to get the information you need.
Counting results
All result types can be counted individually, and the total number of results can be counted as well.
Extend the result classes
Both the OperationResult
and collection classes are designed to be extended,
so you can add your own custom methods to them.
The most common use for this is to correctly document the result subject's type: