brokeyourbike/has-source-model

与源模型交互的接口

2.0.1 2023-05-14 22:18 UTC

This package is auto-updated.

Last update: 2024-09-20 14:20:10 UTC


README

Latest Stable Version Total Downloads Maintainability Test Coverage

与源模型交互的接口。

安装

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
        }
    }
}

作者

许可证

Mozilla公共许可证v2.0