Passed
Push — master ( 9e6d2f...c6b62f )
by Zaahid
06:54
created

UUEncodedPartFactory::newInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 11
nc 2
nop 2
dl 0
loc 14
ccs 12
cts 12
cp 1
crap 2
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the ZBateson\MailMimeParser project.
4
 *
5
 * @license http://opensource.org/licenses/bsd-license.php BSD
6
 */
7
namespace ZBateson\MailMimeParser\Message\Part\Factory;
8
9
use Psr\Http\Message\StreamInterface;
10
use ZBateson\MailMimeParser\Message\Part\UUEncodedPart;
11
use ZBateson\MailMimeParser\Message\Part\PartBuilder;
12
13
/**
14
 * Responsible for creating UUEncodedPart instances.
15
 *
16
 * @author Zaahid Bateson
17
 */
18
class UUEncodedPartFactory extends MessagePartFactory
19
{
20
    /**
21
     * Constructs a new UUEncodedPart object and returns it
22
     * 
23
     * @param PartBuilder $partBuilder
24
     * @param StreamInterface $messageStream
25
     * @return \ZBateson\MailMimeParser\Message\Part\NonMimePart
26
     */
27 1
    public function newInstance(PartBuilder $partBuilder, StreamInterface $messageStream = null)
28
    {
29 1
        $partStream = null;
30 1
        $contentStream = null;
31 1
        if ($messageStream !== null) {
32 1
            $partStream = $this->streamFactory->getLimitedPartStream($messageStream, $partBuilder);
33 1
            $contentStream = $this->streamFactory->getLimitedContentStream($messageStream, $partBuilder);
34
        }
35 1
        return new UUEncodedPart(
36 1
            $this->partStreamFilterManagerFactory->newInstance(),
37 1
            $this->streamFactory,
38 1
            $partBuilder,
39 1
            $partStream,
40 1
            $contentStream
41
        );
42
    }
43
}
44