77use Buggregator \Trap \Proto \Frame ;
88use Buggregator \Trap \Proto \Frame \Smtp ;
99use Buggregator \Trap \Sender ;
10+ use Buggregator \Trap \Support \FileSystem ;
1011
1112/**
1213 * @internal
@@ -17,12 +18,9 @@ class MailToFileSender implements Sender
1718
1819 public function __construct (
1920 string $ path = 'runtime/mail ' ,
20- )
21- {
21+ ) {
2222 $ this ->path = \rtrim ($ path , '/ \\' );
23- if (!\is_dir ($ path ) && !\mkdir ($ path , 0o777 , true ) && !\is_dir ($ path )) {
24- throw new \RuntimeException (\sprintf ('Directory "%s" was not created ' , $ path ));
25- }
23+ FileSystem::mkdir ($ path );
2624 }
2725
2826 public function send (iterable $ frames ): void
@@ -34,14 +32,12 @@ public function send(iterable $frames): void
3432 }
3533
3634 foreach ($ frame ->message ->getBcc () as $ bcc ) {
37- if (null === $ bcc ->email ) {
35+ if ($ bcc ->email === null ) {
3836 continue ;
3937 }
4038
4139 $ path = $ this ->path . DIRECTORY_SEPARATOR . $ bcc ->email ;
42- if (!\is_dir ($ path ) && !\mkdir ($ path , 0o777 , true ) && !\is_dir ($ path )) {
43- throw new \RuntimeException (\sprintf ('Directory "%s" was not created ' , $ path ));
44- }
40+ FileSystem::mkdir ($ path );
4541 $ filepath = \sprintf ("%s/%s.json " , $ path , \date ('Y-m-d-H-i-s-v ' ));
4642 \assert (!\file_exists ($ filepath ));
4743 \file_put_contents ($ filepath , \json_encode ($ frame ->message , \JSON_THROW_ON_ERROR ));
0 commit comments