grifix / repeater
                            This package is abandoned and no longer maintained.
                                                            No replacement package was suggested.
                                                                                    
                                        
                    
                    Repeats code until it returns null
    dev-main
    2023-03-02 08:52 UTC
Requires
- php: ^8.1
 
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.13
 - phpstan/phpstan: ^1.9
 - phpstan/phpstan-phpunit: ^1.3
 - phpunit/phpunit: ^9.5
 
This package is auto-updated.
Last update: 2023-07-26 07:07:10 UTC
README
composer require grifix/repeater
Usage
This code tries to get value from external service 10 times or until external service will return value that is not null:
   Repeater::repeatUntilNotNull(function () use ($externalService): ?string {
        $result = $externalService->getValue();
        if(null === $result){
            sleep(1);
        }
        return $result;
    }, 10);