PHPackages                             gsdevme/stubborn - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. gsdevme/stubborn

ActiveLibrary

gsdevme/stubborn
================

Concept taken from Stubborn https://github.com/derekdowling/stubborn

019PHP

Since Dec 16Pushed 11y ago2 watchersCompare

[ Source](https://github.com/gsdevme/Stubborn)[ Packagist](https://packagist.org/packages/gsdevme/stubborn)[ RSS](/packages/gsdevme-stubborn/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

WIP: Stubborn
-------------

[](#wip-stubborn)

### Travis

[](#travis)

[![Build Status](https://camo.githubusercontent.com/7b51c3bc448a33202b750cd357245f234a60a529d47065e1e31a1e49495c5fd5/68747470733a2f2f7472617669732d63692e6f72672f67736465766d652f53747562626f726e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gsdevme/Stubborn)

### Scrutinizer

[](#scrutinizer)

[![Build Status](https://camo.githubusercontent.com/2cc84178e33de423093f5c409704ac46b4fd6100ed2845a3f1787cbfc81cc216/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67736465766d652f53747562626f726e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gsdevme/Stubborn/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/20c9090c07230a2a797f3b419550c921ba238fd91a86baed204bda795541c6ea/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67736465766d652f53747562626f726e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gsdevme/Stubborn/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/e494431d12714f5a563cc6ff5e1a082c330cf0477fc78e871f9cfddc7be7c36b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67736465766d652f53747562626f726e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gsdevme/Stubborn/?branch=master)

#### Credit

[](#credit)

I was browsing reddit and came across a post.. I like the concept but thought I could improve on the implementation.. so I did

- Reddit: [http://www.reddit.com/r/PHP/comments/2mqyxw/a\_little\_library\_i\_wrote\_for\_dealing\_with/](http://www.reddit.com/r/PHP/comments/2mqyxw/a_little_library_i_wrote_for_dealing_with/)
- Original Developer:

### Concept

[](#concept)

For each API vendor (e.g. Facebook, Twitter, Dropbox) have the requests implement StubbornAwareInterface and throw the class into Stubborn, You can implement the methods to handle the API oddities

### Example

[](#example)

```
class StubbornDummyApi implements \Stubborn\StubbornAwareInterface
{

    private $apiKey;

    public function __construct($apikey)
    {
        $this->apiKey = $apiKey;
    }

    public function getRetryNumber()
    {
        // try twice
        return 1;
    }

    public function getRetryWaitSeconds()
    {
        // wait 5 seconds after each try
        return 10;
    }

    public function run()
    {
        // use the API key or something in the real world?
        $this->apiKey = null;

        // Actual API logic here.. so Facebook, Twitter etc
        return new \Stubborn\StubbornResponse('{"status":true}', 200);
    }

    public function getHttpActionRequest(\Stubborn\StubbornResponseInterface $response)
    {
        // Handle the HTTP code, 501/408 lets retry
        switch($response->getHttpCode()){
            case 501:
            case 408:
                return self::RETRY_ACTION;
            default:
                return false;
        }
    }

    public function getExceptionActionRequest(\Exception $exception)
    {
        switch(true){
            // If UnexpectedValueException retry wait.. maybe got something odd back from the API
            case ($exception instanceof \UnexpectedValueException):
                return self::RETRY_WAIT_ACTION;
            // Default action is to just rethrow the Exception, we don't know what to do with it
            case ($exception instanceof \Exception):
            default:
                throw $exception;
        }
    }
}

$dummyApiRequest = new StubbornDummyApi('123456789qwerty');
$stubborn = new \Stubborn\Stubborn($dummyApiRequest);
$result = $stubborn->run();

if($result instanceOf \Stubborn\StubbornResponseInterface){
    var_dump($result->getHttpCode());
    var_dump($result->getData());
}
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/baa6c222b01edf945aa4e5e362583bac91f303c2a620d8774a9a5a742ade8e07?d=identicon)[gsdev](/maintainers/gsdev)

---

Top Contributors

[![gstaniforthsessiondigital](https://avatars.githubusercontent.com/u/8982860?v=4)](https://github.com/gstaniforthsessiondigital "gstaniforthsessiondigital (47 commits)")[![gsdevme](https://avatars.githubusercontent.com/u/319498?v=4)](https://github.com/gsdevme "gsdevme (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

### Embed Badge

![Health badge](/badges/gsdevme-stubborn/health.svg)

```
[![Health](https://phpackages.com/badges/gsdevme-stubborn/health.svg)](https://phpackages.com/packages/gsdevme-stubborn)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
