brokeyourbike/has-source-model

Interface for interacting with source models

2.0.1 2023-05-14 22:18 UTC

This package is auto-updated.

Last update: 2024-02-20 13:13:45 UTC


README

Latest Stable Version Total Downloads Maintainability Test Coverage

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

License

Mozilla Public License v2.0