Lue dans les fichiers PHP du paquet au commit 24a062b2058b : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.
CapabilitiesclassWhat a provider can be asked, said before it is asked anything, and whose terms apply.
3 methods · 5 properties
ConfigclassA provider's configuration while its factory builds it: the options given, the factory's defaults under them, and the keys that must be filled.
7 methods
ProfileInterfaceinterfaceThe account as it shows itself: name, page, how many fund it, what it receives, its goal.
1 method
ProviderFactoryclassA provider's factory fills a Config - its name ("omnifund.factory_name"), its title ("omnifund.factory_title"), the options it needs ("omnifund.required_options") and the defaults of the others - then builds the provider from it.
3 methods
ProviderFactoryInterfaceinterfaceBuilds a provider from its options (an account, a token...).
2 methods
ProviderInterfaceinterfaceOne funding platform, configured for an account: GitHub Sponsors, Open Collective, Liberapay... Its Capabilities say what it can be asked - the account's profile (ProfileInterface), its public sponsors (SponsorsInterface), the tiers it offers (TiersInterface) - and whose terms apply.
3 methods
RegistryclassThe application's funding providers by name, each built once from its factory and options:
9 methods
SponsorsInterfaceinterfaceWho funds the account, as far as the platform shows them publicly.
1 method
TiersInterfaceinterfaceThe ways to give the account offers.
1 method
InvalidConfigExceptionclassA provider asked for with options it cannot work with, or not configured at all.
NotSupportedExceptionclassA provider asked for what it cannot give: the sponsors of a platform that keeps them private.
1 method
OmnifundExceptioninterfaceEvery exception omnifund throws.
ProviderExceptionclassThe provider answered, and not with what was asked: an error status, an error in a GraphQL answer, no such account.
1 method
UnreachableExceptionclassThe provider could not be reached: a network error, a timeout.
JsonclassA JSON request on the application's HTTP client, its failures turned into omnifund's exceptions; and typed reads of what came back, for providers that walk an answer they do not control.
7 methods
RedactionclassWhat a failed call may carry of its credentials, taken out before the failure leaves the package: an HTTP client's exception quotes the URL called (a key in its query, a password in its user part), and every exception's trace keeps the arguments of the calls under it (the request options, headers and query with the key) unless PHP runs with zend.exception_ignore_args.
5 methods · 1 constant
GoalclassWhat an account says it aims for: an amount (Liberapay, GitHub's MONTHLY_SPONSORSHIP_AMOUNT) or a number of sponsors (GitHub's TOTAL_SPONSORS_COUNT), and how far it has got when the provider says.
2 methods · 6 properties
IncomeclassWhat an account receives, every period: Liberapay counts it by the week, GitHub by the month.
3 methods · 2 properties
MoneyclassAn amount in hundredths of its currency's unit, as the providers count it (GitHub's monthlyPriceInCents, Open Collective's valueInCents, Liberapay's "636.28"), and its ISO 4217 currency.
5 methods · 2 properties
PeriodenumHow often an amount is given: once, or every week, month, year.
1 method · 4 cases
ProfileclassAn account where funding is received, as it shows itself: its name and page, how many fund it, what it receives and what it aims for - each null when the provider does not say.
2 methods · 9 properties
SponsorclassSomeone who funds the account, as the provider shows them publicly: a handle, a name, a picture, a page; their tier, since when and how much when the provider says.
3 methods · 8 properties · 3 constants
TierclassOne way to give that an account offers: "$5 a month", "Backer", a custom amount.
2 methods · 7 properties
ArrayFactoryclassArrayProvider, from its options:
3 options
ArrayProviderclassA provider that answers what it was given: for tests, demos and an application's fixtures.
7 methods
Omnifund
Capabilities class
final readonly class Capabilities Capabilities.php:6
What a provider can be asked, said before it is asked anything, and whose terms apply.
public bool $profilethe account's profile (ProfileInterface)
public bool $sponsorsits public sponsors (SponsorsInterface)
public bool $tiersthe tiers it offers (TiersInterface)
public bool $keywhether a key or token is needed to read it
public array $termsthe terms whoever runs it must follow (URLs)
Capabilities::__construct()
public function __construct(public bool $profile = false, public bool $sponsors = false, public bool $tiers = false, public bool $key = false, public array $terms = [])$profilethe account's profile (ProfileInterface)
$sponsorsits public sponsors (SponsorsInterface)
$tiersthe tiers it offers (TiersInterface)
$keywhether a key or token is needed to read it
$termsthe terms whoever runs it must follow (URLs)
Capabilities::contracts()
public function contracts(): array- Returns
what it can be asked, by contract: profile, sponsors, tiers
Capabilities::toArray()
public function toArray(): arrayConfig class
final class Config extends ArrayObject Config.php:14
A provider's configuration while its factory builds it: the options given, the factory's defaults under them, and the keys that must be filled.
Config::defaults()
public function defaults(array $defaults): selfSets each key not set yet.
Config::validateNotEmpty()
public function validateNotEmpty(array $keys): voidConfig::get()
public function get(string $key, mixed $default = null): mixedConfig::string()
public function string(string $key): ?stringA string option; null when it is empty.
Config::int()
public function int(string $key, int $default = 0): intConfig::float()
public function float(string $key, float $default = 0.0): floatConfig::bool()
public function bool(string $key): boolA boolean option, as an environment variable gives it too: "1", "true", "yes", "on".
ProfileInterface interface
interface ProfileInterface extends ProviderInterface ProfileInterface.php:8
The account as it shows itself: name, page, how many fund it, what it receives, its goal.
ProfileInterface::profile()
public function profile(?string $account = null): Profile$accountanother account than the configured one
ProviderFactory class
abstract class ProviderFactory implements ProviderFactoryInterface ProviderFactory.php:15
A provider's factory fills a Config - its name ("omnifund.factory_name"), its title ("omnifund.factory_title"), the options it needs ("omnifund.required_options") and the defaults of the others - then builds the provider from it.
Nothing here calls anything: a factory whose provider is reached over HTTP takes its client in its own constructor - the application's, a MockHttpClient in a test.
ProviderFactory::getName()
public function getName(): stringProviderFactory::create()
public function create(array $options = []): ProviderInterfaceProviderFactory::createConfig()
public function createConfig(array $options = []): ConfigProviderFactoryInterface interface
interface ProviderFactoryInterface ProviderFactoryInterface.php:6
Builds a provider from its options (an account, a token...).
ProviderFactoryInterface::getName()
public function getName(): stringThe name providers are configured with: "github-sponsors", "liberapay".
..
ProviderFactoryInterface::create()
public function create(array $options = []): ProviderInterfaceProviderInterface interface
interface ProviderInterface ProviderInterface.php:12
One funding platform, configured for an account: GitHub Sponsors, Open Collective, Liberapay... Its Capabilities say what it can be asked - the account's profile (ProfileInterface), its public sponsors (SponsorsInterface), the tiers it offers (TiersInterface) - and whose terms apply.
ProviderInterface::getName()
public function getName(): stringThe factory's name: "github-sponsors", "opencollective", "liberapay".
..
ProviderInterface::getTitle()
public function getTitle(): stringProviderInterface::capabilities()
public function capabilities(): CapabilitiesRegistry class
final class Registry Registry.php:20
The application's funding providers by name, each built once from its factory and options:
$registry = new Registry([new GitHubSponsorsFactory($http), new LiberapayFactory($http)], [ 'github' => ['factory' => 'github-sponsors', 'options' => ['account' => 'glitchr-studio', 'token' => '...']], 'liberapay' => ['factory' => 'liberapay', 'options' => ['account' => 'Liberapay']], ]);
$registry->profile('liberapay')->profile()->sponsors; $registry->sponsors('github')->sponsors();
Registry::__construct()
public function __construct(iterable $factories, readonly array $config)Registry::get()
public function get(string $name): ProviderInterfaceRegistry::has()
public function has(string $name): boolRegistry::profile()
public function profile(string $name): ProfileInterfaceThe provider, as the account's profile.
Registry::sponsors()
public function sponsors(string $name): SponsorsInterfaceThe provider, as the account's public sponsors.
Registry::tiers()
public function tiers(string $name): TiersInterfaceThe provider, as the tiers the account offers.
Registry::options()
public function options(string $name): array- Returns
the options a provider is configured with
Registry::names()
public function names(): array- Returns
the configured providers' names
Registry::factories()
public function factories(): array- Returns
the factories installed: what
factory:may name
SponsorsInterface interface
interface SponsorsInterface extends ProviderInterface SponsorsInterface.php:8
Who funds the account, as far as the platform shows them publicly.
SponsorsInterface::sponsors()
public function sponsors(?string $account = null, ?int $limit = null): array$accountanother account than the configured one
$limitat most this many; null: every one, page after page
TiersInterface interface
interface TiersInterface extends ProviderInterface TiersInterface.php:8
The ways to give the account offers.
TiersInterface::tiers()
public function tiers(?string $account = null): array$accountanother account than the configured one
Omnifund\Exception
InvalidConfigException class
final class InvalidConfigException extends InvalidArgumentException implements OmnifundException InvalidConfigException.php:6
A provider asked for with options it cannot work with, or not configured at all.
NotSupportedException class
final class NotSupportedException extends LogicException implements OmnifundException NotSupportedException.php:6
A provider asked for what it cannot give: the sponsors of a platform that keeps them private.
NotSupportedException::capability()
public static function capability(object $provider, string $name, string $capability): selfOmnifundException interface
interface OmnifundException extends Throwable OmnifundException.php:6
Every exception omnifund throws.
ProviderException class
final class ProviderException extends RuntimeException implements OmnifundException ProviderException.php:6
The provider answered, and not with what was asked: an error status, an error in a GraphQL answer, no such account.
ProviderException::answered()
public static function answered(string $provider, string $what, int|string $status): selfUnreachableException class
final class UnreachableException extends RuntimeException implements OmnifundException UnreachableException.php:6
The provider could not be reached: a network error, a timeout.
Omnifund\Http
Json class
final class Json Json.php:15
A JSON request on the application's HTTP client, its failures turned into omnifund's exceptions; and typed reads of what came back, for providers that walk an answer they do not control.
Json::request()
public static function request(HttpClientInterface $http, string $method, string $url, array $options, string $provider, string $what): array$optionsthe client's options (headers, json, query...)
- Returns
the decoded answer
Json::get()
public static function get(mixed $data, string|int ...$path): mixedThe value at a path of keys; null when any step is missing.
Json::string()
public static function string(mixed $data, string|int ...$path): ?stringA non-empty string at the path, or null.
Json::int()
public static function int(mixed $data, string|int ...$path): ?intJson::bool()
public static function bool(mixed $data, string|int ...$path): boolJson::list()
public static function list(mixed $data, string|int ...$path): array- Returns
the list at the path; empty when there is none
Json::date()
public static function date(mixed $data, string|int ...$path): ?\DateTimeImmutableA date at the path, or null.
Redaction class
final class Redaction Redaction.php:22
What a failed call may carry of its credentials, taken out before the failure leaves the package: an HTTP client's exception quotes the URL called (a key in its query, a password in its user part), and every exception's trace keeps the arguments of the calls under it (the request options, headers and query with the key) unless PHP runs with zend.exception_ignore_args.
copy() gives the previous exception to wrap instead of the client's own: the same class and code, its message with the key's parameters, the user part and every secret value replaced by ***, its trace without arguments, its own previous copied the same way. Properties of the client's class beyond those of \Exception are not copied (a Symfony HttpException's response, a PSR-18 exception's request: their URL holds the key). withoutArguments() takes the arguments out of the trace of the exception thrown in its place.
const MASK = '***'
Redaction::secrets()
public static function secrets(string $url, array $options = []): arrayThe secrets a request carries: the values of its query parameters, headers and body fields named as credentials (key, token, secret, password, signature, auth...), a bearer token, a basic password, the URL's user part.
$optionsthe HTTP client's options
Redaction::sensitive()
public static function sensitive(string $name): boolWhether a parameter, header or field of this name holds a credential.
Redaction::text()
public static function text(string $text, array $secrets = []): stringA text without credentials: in every address, the user part and the parameters named as credentials masked (api_key=***); then every secret given, raw or URL-encoded, masked wherever it stands.
Redaction::copy()
public static function copy(\Throwable $failure, array $secrets = []): \ThrowableA copy of a failure to wrap in its place: its class, code, file and line, its message through text(), its trace without arguments, its previous copied the same way.
Redaction::withoutArguments()
public static function withoutArguments(\Throwable $failure): \ThrowableThe failure given, the arguments out of its trace (and out of its previous ones'), as zend.exception_ignore_args would have left it.
Omnifund\Model
Goal class
final readonly class Goal Goal.php:10
What an account says it aims for: an amount (Liberapay, GitHub's MONTHLY_SPONSORSHIP_AMOUNT) or a number of sponsors (GitHub's TOTAL_SPONSORS_COUNT), and how far it has got when the provider says.
public ?string $titlepublic ?string $descriptionpublic ?Money $amountpublic ?Period $periodpublic ?int $sponsorspublic ?int $percent
Goal::__construct()
public function __construct(public ?string $title = null, public ?string $description = null, public ?Money $amount = null, public ?Period $period = null, public ?int $sponsors = null, public ?int $percent = null)Goal::toArray()
public function toArray(): arrayIncome class
final readonly class Income Income.php:6
What an account receives, every period: Liberapay counts it by the week, GitHub by the month.
public Money $amountpublic Period $period
Income::__construct()
public function __construct(public Money $amount, public Period $period)Income::monthly()
public function monthly(): ?MoneyThe same income by the month (a week is 52/12 of a month); null for a one-time amount.
Income::toArray()
public function toArray(): arrayMoney class
final readonly class Money Money.php:12
An amount in hundredths of its currency's unit, as the providers count it (GitHub's monthlyPriceInCents, Open Collective's valueInCents, Liberapay's "636.28"), and its ISO 4217 currency.
public string $currencypublic int $cents
Money::__construct()
public function __construct(public int $cents, string $currency)Money::fromDecimal()
public static function fromDecimal(string|int|float $amount, string $currency): selfFrom a decimal amount: "636.28", 636.28, 5.
Money::decimal()
public function decimal(): string"636.28"
Money::multiply()
public function multiply(float $factor): selfMoney::toArray()
public function toArray(): arrayPeriod enum
enum Period Period.php:6
How often an amount is given: once, or every week, month, year.
case Once = 'once'case Week = 'week'case Month = 'month'case Year = 'year'
Period::perMonth()
public function perMonth(): ?floatHow many of this period make a month (52 weeks a year); null for a one-time amount.
Profile class
final readonly class Profile Profile.php:10
An account where funding is received, as it shows itself: its name and page, how many fund it, what it receives and what it aims for - each null when the provider does not say.
public string $providerpublic string $handlepublic ?string $namepublic ?string $descriptionpublic ?string $urlpublic ?string $avatarUrlpublic ?int $sponsorspublic ?Income $incomepublic ?Goal $goal
Profile::__construct()
public function __construct(public string $provider, public string $handle, public ?string $name = null, public ?string $description = null, public ?string $url = null, public ?string $avatarUrl = null, public ?int $sponsors = null, public ?Income $income = null, public ?Goal $goal = null)Profile::toArray()
public function toArray(): arraySponsor class
final readonly class Sponsor Sponsor.php:10
Someone who funds the account, as the provider shows them publicly: a handle, a name, a picture, a page; their tier, since when and how much when the provider says.
const USER = 'user'const ORGANIZATION = 'organization'const OTHER = 'other'public string $handlepublic ?string $namepublic ?string $avatarUrlpublic ?string $urlpublic string $kindpublic ?\DateTimeImmutable $sincepublic ?string $tierpublic ?Money $total
Sponsor::__construct()
public function __construct(public string $handle, public ?string $name = null, public ?string $avatarUrl = null, public ?string $url = null, public string $kind = self::USER, public ?\DateTimeImmutable $since = null, public ?string $tier = null, public ?Money $total = null)Sponsor::label()
public function label(): stringThe name shown: the name, or the handle.
Sponsor::toArray()
public function toArray(): arrayTier class
final readonly class Tier Tier.php:6
One way to give that an account offers: "$5 a month", "Backer", a custom amount.
public string $namepublic ?Money $pricepublic Period $periodpublic ?string $idpublic ?string $descriptionpublic bool $customAmountpublic ?Money $minimum
Tier::__construct()
public function __construct(public string $name, public ?Money $price = null, public Period $period = Period::Month, public ?string $id = null, public ?string $description = null, public bool $customAmount = false, public ?Money $minimum = null)Tier::toArray()
public function toArray(): arrayOmnifund\Testing
ArrayFactory class
final class ArrayFactory extends ProviderFactory ArrayFactory.php:20
ArrayProvider, from its options:
profile a Model\Profile (required) sponsors a list of Model\Sponsor tiers a list of Model\Tier
Options
| Option | Default | |
|---|---|---|
sponsors | [] | |
tiers | [] | |
profile | required |
ArrayProvider class
final class ArrayProvider implements ProfileInterface, SponsorsInterface, TiersInterface ArrayProvider.php:14
A provider that answers what it was given: for tests, demos and an application's fixtures.
ArrayProvider::__construct()
public function __construct(readonly Profile $profile, readonly array $sponsors = [], readonly array $tiers = [])ArrayProvider::getName()
public function getName(): stringArrayProvider::getTitle()
public function getTitle(): stringArrayProvider::capabilities()
public function capabilities(): CapabilitiesArrayProvider::profile()
public function profile(?string $account = null): ProfileArrayProvider::sponsors()
public function sponsors(?string $account = null, ?int $limit = null): arrayArrayProvider::tiers()
public function tiers(?string $account = null): array