Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
BillingException
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
6 / 6
6
100.00% covered (success)
100.00%
1 / 1
 disabled
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 planNotFound
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 couponInvalid
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 couponNotApplicable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 downgradeBlocked
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 checkoutFailed
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace ImovelZapAi\Billing\Domain\Exceptions;
6
7use RuntimeException;
8
9final class BillingException extends RuntimeException
10{
11    public static function disabled(): self
12    {
13        return new self('Cobrança está desabilitada neste ambiente.');
14    }
15
16    public static function planNotFound(string $code): self
17    {
18        return new self("Plano [{$code}] não encontrado.");
19    }
20
21    public static function couponInvalid(): self
22    {
23        return new self('Cupom inválido ou expirado.');
24    }
25
26    public static function couponNotApplicable(): self
27    {
28        return new self('Este cupom não se aplica ao plano selecionado.');
29    }
30
31    public static function downgradeBlocked(string $resource, int $current, int $limit): self
32    {
33        return new self("Não é possível reduzir o plano: há {$current} {$resource}, e o novo limite é {$limit}. Remova o excesso antes.");
34    }
35
36    public static function checkoutFailed(string $detail): self
37    {
38        return new self('Não foi possível iniciar o checkout: '.$detail);
39    }
40}