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