/** * @param Client $client * @param mixed $charges * @return AbstractBill * @throws BillingMethodNotSupported */ public function bill(Client $client, $charges) { if (array_key_exists($client->getBillingType(), $this->billingMethods)) { $class = $this->billingMethods[$client->getBillingType()]; return new $class($charges); } throw new BillingMethodNotSupported("Billing method " . $client->getBillingType() . " is not supported."); }
public function it_throws_an_exception_if_the_clients_billing_type_is_unsupported(Client $client) { $client->getBillingType()->willReturn('hourly'); $this->shouldThrow(BillingMethodNotSupported::class)->duringBill($client, "charges"); }