Interface for interacting with source models.
composer require brokeyourbike/has-source-model
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
}
}
}
- Ivan Stasiuk | Twitter | LinkedIn | stasi.uk