Completed
Push — master ( 74fe50...0f19ea )
by Zaahid
09:04
created

MimePartFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 57
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A newMimePart() 0 4 1
A newNonMimePart() 0 4 1
A newUUEncodedPart() 0 4 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;
8
9
use ZBateson\MailMimeParser\Header\HeaderFactory;
10
use ZBateson\MailMimeParser\Message\Writer\MessageWriterService;
11
12
/**
13
 * Description of MimePartFactory
14
 *
15
 * @author Zaahid Bateson
16
 */
17
class MimePartFactory
18
{
19
    /**
20
     * @var \ZBateson\MailMimeParser\Header\HeaderFactory the HeaderFactory
21
     *      instance
22
     */
23
    protected $headerFactory;
24
    
25
    /**
26
     * @var \ZBateson\MailMimeParser\Message\Writer\MessageWriterService the
27
     * MessageWriterService responsible for returning writers
28
     */
29
    protected $messageWriterService;
30
    
31
    /**
32
     * Creates a MimePartFactory instance with its dependencies.
33
     * 
34
     * @param HeaderFactory $headerFactory
35
     * @param MessageWriterService $messageWriterService
36
     */
37 3
    public function __construct(HeaderFactory $headerFactory, MessageWriterService $messageWriterService)
38
    {
39 3
        $this->headerFactory = $headerFactory;
40 3
        $this->messageWriterService = $messageWriterService;
41 3
    }
42
    
43
    /**
44
     * Constructs a new MimePart object and returns it
45
     * 
46
     * @return \ZBateson\MailMimeParser\Message\MimePart
47
     */
48 1
    public function newMimePart()
49
    {
50 1
        return new MimePart($this->headerFactory, $this->messageWriterService->getMimePartWriter());
51
    }
52
    
53
    /**
54
     * Constructs a new NonMimePart object and returns it
55
     * 
56
     * @return \ZBateson\MailMimeParser\Message\NonMimePart
57
     */
58 1
    public function newNonMimePart()
59
    {
60 1
        return new NonMimePart($this->headerFactory, $this->messageWriterService->getMimePartWriter());
61
    }
62
    
63
    /**
64
     * Constructs a new UUEncodedPart object and returns it
65
     * 
66
     * @param int $mode
67
     * @param string $filename
68
     */
69 1
    public function newUUEncodedPart($mode, $filename)
70
    {
71 1
        return new UUEncodedPart($this->headerFactory, $this->messageWriterService->getMimePartWriter(), $mode, $filename);
72
    }
73
}
74