Lines n/a 0 / 0
Functions and Methods n/a 0 / 0
Classes and Traits n/a 0 / 0
Name Lines Functions and Methods CRAP Classes and Traits
1<?php
2
3declare(strict_types=1);
4
5namespace Tomaj\BankMailsParser\Parser;
6
7use Tomaj\BankMailsParser\Exception\InvalidEmailFormatException;
8use Tomaj\BankMailsParser\MailContent;
9
10/**
11 * What a bank parser must provide so the facade can select it and read every transaction.
12 *
13 * Single-transaction parse() and tryParse() stay on the concrete parser (the ParsesBankMail
14 * trait supplies tryParse()). They are not part of this interface: a custom parser only has
15 * to detect a mail, name its domains, and return every transaction.
16 */
17interface ParserInterface
18{
19    /**
20     * Check if this parser can handle the given email content.
21     */
22    public function supports(string $content, ?string $sender = null, ?string $subject = null): bool;
23
24    /**
25     * Parse every transaction in the email.
26     *
27     * @return list<MailContent>
28     * @throws InvalidEmailFormatException if email format is recognized but invalid
29     */
30    public function parseAll(string $content): array;
31
32    /**
33     * Hosts this parser may read when the caller passes a sender.
34     *
35     * An empty list means the parser is used only when the sender is omitted.
36     * Pass the sender. A parser with an empty list is skipped when a sender is set.
37     *
38     * @return list<string>
39     */
40    public function bankDomains(): array;
41}