brokeyourbike / has-source-model
Interface for interacting with source models
Fund package maintenance!
brokeyourbike
Open Collective
Requires
- php: ^7.4|^8.0
Requires (Dev)
- bamarni/composer-bin-plugin: ^1.4
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-20 14:41:36 UTC
README
Interface for interacting with source models.
Installation
composer require brokeyourbike/has-source-model
Usage
use BrokeYourBike\HasSourceModel\HasSourceModelInterface; use BrokeYourBike\HasSourceModel\HasSourceModelTrait; class Client implements HasSourceModelInterface { use HasSourceModelTrait; public function fetchTransaction(Transaction $transaction) { $this->setSourceModel($transaction); $this->performRequest("transactions/{$transaction->id}"); } private function performRequest(string $url) { if ($this->getSourceModel($transaction)) { // do something with it } } }
Authors
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk