MimePartAttachmentParser   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 19
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 8 2
1
<?php
2
declare(strict_types=1);
3
4
namespace AcMailer\Attachment\Parser;
5
6
use AcMailer\Attachment\Helper\AttachmentHelperTrait;
7
use AcMailer\Exception\InvalidAttachmentException;
8
use Zend\Mime;
9
10
class MimePartAttachmentParser implements AttachmentParserInterface
11
{
12
    use AttachmentHelperTrait;
13
14
    /**
15
     * @param string|resource|array|Mime\Part $attachment
16
     * @param string|null $attachmentName
17
     * @return Mime\Part
18
     * @throws InvalidAttachmentException
19
     */
20
    public function parse($attachment, string $attachmentName = null): Mime\Part
21
    {
22
        if (! $attachment instanceof Mime\Part) {
23
            throw InvalidAttachmentException::fromExpectedType(Mime\Part::class);
24
        }
25
26
        return $this->applyNameToPart($attachment, $attachmentName);
27
    }
28
}
29