humans/avatars

1.1.0 2024-03-16 03:43 UTC

This package is auto-updated.

Last update: 2024-04-16 04:00:53 UTC


README

This package allows downloads from multiple providers and it returns the first successful result.

Setup

composer require humans/avatars

Usage

This will return the first successful photo.

use Humans\Avatars\Facades\Avatars;
use Humans\Avatars\Attempt;
use Humans\Avatars\Providers;

$response = Avatars::attempt(
    new Providers\Unavatar('jaggy@humans.ph'),
    new Providers\Unavatar('jaggy'),
    new Providers\Unavatar('jaggy@hey.com'),
    new Providers\UiAvatars('Jaggy Gauran'),
);

$response->contents;
$response->extension;

Testing

Avatars provides two testing fakes to make testing a lot easier.

Force a success with specific contents

Avatars::pass('example image content', 'gif');

Force the avatar to fail

Avatars::fail();