PHP Classes

PHP Retry Library: Keep calling a function until it meets a condition

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 271 All time: 7,712 This week: 660Up
Version License PHP version Categories
retryclass 1.0.0MIT/X Consortium ...5PHP 5, Time and Date, Language
Description 

Author

This simple class can keep calling a function until it meets a condition.

It takes a given callback function and calls it to check if it returns a value that states that a certain condition is meet.

Until the condition state is reached, the class keeps calling the function after a given period of time, which by default is one minute.

Innovation Award
PHP Programming Innovation award nominee
March 2018
Number 3


Prize: One downloadable copy of Komodo IDE
Sometimes applications need to wait for conditions that may take some time to happen, like for instance waiting for a given period to pass until you execute a periodic task.

This package can help implementing these tasks that need to be repeated after a given time interval until a certain condition is met.

Manuel Lemos
Picture of Arnel Labarda
  Performance   Level  
Name: Arnel Labarda <contact>
Classes: 6 packages by
Country: Philippines Philippines
Age: 37
All time rank: 247922 in Philippines Philippines
Week rank: 215 Up4 in Philippines Philippines Up
Innovation award
Innovation award
Nominee: 4x

Winner: 1x

Example

<?php

// will retry 5 times by default at 1 minute interval
$retry_command = new RetryCall;

$retry_command->retry(function() {
   
$elephant = 1;
   
$ant = 0;

    return
$ant >= $elephant;
});


  Files folder image Files (2)  
File Role Description
Accessible without login Plain text file example.php Example example usage
Plain text file retry-class.php Class retry class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:271
This week:0
All time:7,712
This week:660Up