Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
75.00% |
6 / 8 |
AttributeMissingException | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
3.14 | |
75.00% |
6 / 8 |
__construct | |
0.00% |
0 / 1 |
2.01 | |
85.71% |
6 / 7 |
|||
getType | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
1 | <?php |
2 | |
3 | namespace Proton\IosReceiptParser\Exception; |
4 | |
5 | use Proton\IosReceiptParser\Attribute\AttributeType; |
6 | use Throwable; |
7 | |
8 | final class AttributeMissingException extends \Exception |
9 | { |
10 | /** @var int */ |
11 | private $type; |
12 | |
13 | /** |
14 | * @throws \Exception |
15 | */ |
16 | public function __construct(int $type, string $context = null, $code = 0, Throwable $previous = null) |
17 | { |
18 | $typeField = AttributeType::getJsonFieldName($type) ?? $type; |
19 | $typeDescription = AttributeType::getHumanFieldDescription($type); |
20 | |
21 | $message = $context === null |
22 | ? sprintf('Required attribute %s (%s) is missing', $typeField, $typeDescription) |
23 | : sprintf('Required attribute %s (%s) is missing from %s', $typeField, $typeDescription, $context); |
24 | |
25 | parent::__construct($message, $code, $previous); |
26 | } |
27 | |
28 | public function getType(): int |
29 | { |
30 | return $this->type; |
31 | } |
32 | } |