1 | <?php declare(strict_types = 1); |
||
8 | class EmailBuilder |
||
9 | { |
||
10 | /** |
||
11 | * @var PartResolverRegistry |
||
12 | */ |
||
13 | private $registry; |
||
14 | |||
15 | /** |
||
16 | * @var EmailPart[] |
||
17 | */ |
||
18 | private $parts; |
||
19 | |||
20 | /** |
||
21 | * Constructor. |
||
22 | * |
||
23 | * @param PartResolverRegistry $registry |
||
24 | */ |
||
25 | 2 | public function __construct(PartResolverRegistry $registry) |
|
29 | |||
30 | /** |
||
31 | * Add part to email. |
||
32 | * |
||
33 | * @param EmailPart $part |
||
34 | * |
||
35 | * @return self |
||
36 | */ |
||
37 | 2 | public function add(EmailPart $part): self |
|
43 | |||
44 | /** |
||
45 | * Build email from parts. |
||
46 | * |
||
47 | * @param Email $email |
||
48 | * |
||
49 | * @return Email |
||
50 | */ |
||
51 | 1 | public function build(Email $email): Email |
|
60 | } |
||
61 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.