Test Failed
Branch 1.0.0 (84f469)
by Zaahid
05:36
created

PartBuilderFactory::newPartBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 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\Message\Part;
8
9
use ZBateson\MailMimeParser\Header\HeaderFactory;
10
11
/**
12
 * Responsible for creating PartBuilder instances.
13
 * 
14
 * The PartBuilder instance must be constructed with a MessagePartFactory
15
 * instance to construct a MessagePart sub-class after parsing a message into
16
 * PartBuilder instances.
17
 *
18
 * @author Zaahid Bateson
19
 */
20
class PartBuilderFactory
21
{
22
    /**
23
     * @var \ZBateson\MailMimeParser\Header\HeaderFactory the HeaderFactory
24
     *      instance
25
     */
26
    protected $headerFactory;
27
    
28
    /**
29
     * @var string the PartStream protocol used to create part and content
30
     *      filenames for fopen
31
     */
32
    private $streamWrapperProtocol = null;
33
    
34
    /**
35
     * Creates a MimePartFactory instance with its dependencies.
36
     * 
37
     * @param HeaderFactory $headerFactory
38
     * @param string $streamWrapperProtocol
39
     */
40
    public function __construct(HeaderFactory $headerFactory, $streamWrapperProtocol)
41
    {
42
        $this->headerFactory = $headerFactory;
43
        $this->streamWrapperProtocol = $streamWrapperProtocol;
44
    }
45
    
46
    /**
47
     * Constructs a new PartBuilder object and returns it
48
     * 
49
     * @param \ZBateson\MailMimeParser\Message\Part\MessagePartFactory
50
     *        $messagePartFactory 
51
     * @return \ZBateson\MailMimeParser\Message\Part\PartBuilder
52
     */
53
    public function newPartBuilder(MessagePartFactory $messagePartFactory)
54
    {
55
        return new PartBuilder(
56
            $this->headerFactory,
57
            $messagePartFactory,
58
            $this->streamWrapperProtocol
59
        );
60
    }
61
}
62