我希望能够使用如下对象来检索新订单和新发票。我觉得它是最易读的,但是我在编写 PHP 类以这种方式工作时遇到了麻烦。
$amazon = new Amazon();
$amazon->orders('New')->get();
$amazon->invoices('New')->get();
在我的 PHP 类中,我的 get() 方法如何区分是返回订单还是发票?
<?php
namespace App\Vendors;
class Amazon
{
private $api_key;
public $orders;
public $invoices;
public function __construct()
{
$this->api_key = config('api.key.amazon');
}
public function orders($status = null)
{
$this->orders = 'orders123';
return $this;
}
public function invoices($status = null)
{
$this->invoices = 'invoices123';
return $this;
}
public function get()
{
// what is the best way to return order or invoice property
// when method is chained?
}
}