Lines 100.00% 2 / 2
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
InvalidEmailFormatException 100.00% 2 / 2 100.00% 2 / 2 2 100.00% 1 / 1
 missingRequiredField 100.00% 1 / 1 100.00% 1 / 1 1
 malformedContent 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Tomaj\BankMailsParser\Exception;
6
7/**
8 * Thrown when email format is recognized but required fields are missing or malformed.
9 */
10final class InvalidEmailFormatException extends ParseException
11{
12    public static function missingRequiredField(string $parserClass, string $fieldName, ?\Throwable $previous = null): self
13    {
14        return new self(sprintf('Parser %s: required field "%s" is missing or invalid', $parserClass, $fieldName), 0, $previous);
15    }
16
17    public static function malformedContent(string $parserClass, string $reason, ?\Throwable $previous = null): self
18    {
19        return new self(sprintf('Parser %s: %s', $parserClass, $reason), 0, $previous);
20    }
21}