artbyrab / integrio
Integrity check interfaces for your PHP library.
Requires
- php: >=8
Requires (Dev)
This package is not auto-updated.
Last update: 2025-04-20 20:54:53 UTC
README
Integrio is a set of interfaces for building integrity checks for your products or features in PHP. Think of Integrio as the base skeleton for you to use as a foundation for your product and feature integrity code checks.
Example
You have customer records that you store in your database. However, there have been occasions where the customer records or their related sub records end up in states you dont expect. How can you solve this? Well before you can think about solving it, it's useful to be able to identify these states where the customer records or their related records have entered an invalid state. Essentially they would not pass an integrity check which is what we will validate.
Therefore we can use Integrio as a foundation to add code class that identify these invalid states which you can then include or call in console commands or cron jobs to check the state of the customer records.
For example you might want to check the customer records integrity by doing things like:
- Check that customers do not have any enquiries that are in a 'Pending' state older than 7 days
- Check that customers do not have any enquiries that are in an 'Errored' state
Integrio adds the class and interface framework for this to be easily done in a fairly basic but uniform way. For example we can use:
- IntegrityCheckInterface.php for the CustomerRecordsIntegrityCheck.php class
- ScenarioCheckInterface.php for:
- EnquiriesErroredStateScenarioCheck.php
- EnquiriesPendingStateScenarioCheck
- All of the above would return a Result.php object which implements the ResultInterface.php class
An example of the CustomerRecordsIntegrityCheck->run() method as JSON:
{
"Title": "Customer records integrity check",
"State": "Fail",
"Description": "The customer records integrity check failed.",
"Resolution": "Check the sub result resolutions to resolve any issues.",
"Sub Results": [
{
"Title": "Customer enquiries errored scenario check",
"State": "Fail",
"Description": "There should not be customer enquiries in a state of 'Errored' as they should all be processed.",
"Resolution": "Run the 'updateCustomerEnquiriesState' command to process the customer enquiries with a 'Errored' state or check the resolution of the individual records.",
"Sub Results": [
{
"Title": "A single customer enquiry errored scenario check",
"State": "Fail",
"Description": "Customer enquiry with an ID of 6 has an invalid state of 'Errored'",
"Resolution": "Run the 'updateCustomerEnquiriesState --customerEnquiryID=6' command to try and reprocess this record individually."
},
{
"Title": "A single customer enquiry errored scenario check",
"State": "Fail",
"Description": "Customer enquiry with an ID of 12 has an invalid state of 'Errored'",
"Resolution": "Run the 'updateCustomerEnquiriesState --customerEnquiryID=12' command to try and reprocess this record individually."
}
]
},
{
"Title": "Customer enquiries pending scenario check",
"State": "Fail",
"Description": "There should not be customer enquiries in a state of 'Pending' as they should all be processed.",
"Resolution": "Run the 'updateCustomerEnquiriesState' command to process the customer enquiries with a 'Pending' state."
}
]
}
For more detailed information see the usage guide:
Requirements
- PHP 8+
Features
- Integrity check interfaces for your PHP library
- Write code to check your systems and features integrity by implementing Integrio interfaces
Installation
The reccomended way to install is via Composer. Either install in the project via terminal
composer require artbyrab/integrio:~1.0
or add it to your composer.json file
"artbyrab/integrio": "~1.0"
Usage
Follow the usage guide