public function get($id)
{
$payment_methods = $this->models;
if (isset($payment_methods[$id])) {
return $payment_methods[$id];
}
$matches = array_filter($payment_methods, function ($payment_method) use($id) {
return $payment_method->get('label') == $id;
});
if (empty($matches)) {
throw new TerminusNotFoundException('Could not locate a payment method identified by {id} on this account.', compact('id'));
} else {
if (count($matches) > 1) {
throw new TerminusException('More than one payment method matched {id}.', compact('id'));
}
}
return array_shift($matches);
}