Full implemantation
This commit is contained in:
31
api/common/Service/Remote/Attachments.php
Normal file
31
api/common/Service/Remote/Attachments.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace ProVM\Common\Service\Remote;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Ddeboer\Imap\ConnectionInterface;
|
||||
use Ddeboer\Imap\MessageInterface;
|
||||
use Ddeboer\Imap\Message\AttachmentInterface;
|
||||
use ProVM\Common\Exception\Attachment\NotFound;
|
||||
|
||||
class Attachments extends Base
|
||||
{
|
||||
public function __construct(ConnectionInterface $connection, LoggerInterface $logger)
|
||||
{
|
||||
$this->setConnection($connection)
|
||||
->setLogger($logger);
|
||||
}
|
||||
|
||||
public function getAttachments(MessageInterface $message): array
|
||||
{
|
||||
return $message->getAttachments();
|
||||
}
|
||||
public function get(MessageInterface $message, string $filename): AttachmentInterface
|
||||
{
|
||||
foreach ($message->getAttachments() as $attachment) {
|
||||
if ($attachment->getFilename() === $filename) {
|
||||
return $attachment;
|
||||
}
|
||||
}
|
||||
throw new NotFound($message, $filename);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user