Passed
Pull Request — master (#171)
by Zaahid
03:23
created

PartBuilderFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 4
b 0
f 0
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A newPartBuilder() 0 3 1
A newChildPartBuilder() 0 6 1
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\Parser;
8
9
use ZBateson\MailMimeParser\Message\PartHeaderContainer;
10
use ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxy;
11
use Psr\Http\Message\StreamInterface;
12
13
/**
14
 * Responsible for creating PartBuilder instances.
15
 *
16
 * @author Zaahid Bateson
17
 */
18
class PartBuilderFactory
19
{
20
    /**
21
     * Constructs a top-level (message) PartBuilder object and returns it
22
     *
23
     * @param PartHeaderContainer $headerContainer
24
     * @param StreamInterface $messageStream
25
     * @return PartBuilder
26
     */
27 105
    public function newPartBuilder(PartHeaderContainer $headerContainer, StreamInterface $messageStream)
28
    {
29 105
        return new PartBuilder($headerContainer, $messageStream);
30
    }
31
32
    /**
33
     * Constructs a child PartBuilder object with the passed $parent as its
34
     * parent, and returns it
35
     *
36
     * @param PartHeaderContainer $headerContainer
37
     * @param ParserPartProxy $parent
38
     * @return PartBuilder
39
     */
40 74
    public function newChildPartBuilder(PartHeaderContainer $headerContainer, ParserPartProxy $parent)
41
    {
42 74
        return new PartBuilder(
43 74
            $headerContainer,
44 74
            null,
45 74
            $parent
46
        );
47
    }
48
}
49