Completed
Push — master ( d4566f...31a5e9 )
by Zaahid
02:27
created

HeaderPartFactory::newAddressGroupPart()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
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\Header\Part;
8
9
/**
10
 * Constructs and returns HeaderPart objects.
11
 *
12
 * @author Zaahid Bateson
13
 */
14
class HeaderPartFactory
15
{
16
    /**
17
     * Creates and returns a default HeaderPart for this factory, allowing
18
     * subclass factories for specialized HeaderParts.
19
     * 
20
     * The default implementation returns a new Token.
21
     * 
22
     * @param string $value
23
     * @return Token
24
     */
25
    public function newInstance($value)
26
    {
27
        return $this->newToken($value);
28
    }
29
    
30
    /**
31
     * Initializes and returns a new Token.
32
     * 
33
     * @param string $value
34
     * @return \ZBateson\MailMimeParser\Header\Part\Token
35
     */
36
    public function newToken($value)
37
    {
38
        return new Token($value);
39
    }
40
    
41
    /**
42
     * Initializes and returns a new LiteralPart.
43
     * 
44
     * @param string $value
45
     * @return \ZBateson\MailMimeParser\Header\Part\LiteralPart
46
     */
47
    public function newLiteralPart($value)
48
    {
49
        return new LiteralPart($value);
50
    }
51
    
52
    /**
53
     * Initializes and returns a new MimeLiteralPart.
54
     * 
55
     * @param string $value
56
     * @return \ZBateson\MailMimeParser\Header\Part\MimeLiteralPart
57
     */
58
    public function newMimeLiteralPart($value)
59
    {
60
        return new MimeLiteralPart($value);
61
    }
62
    
63
    /**
64
     * Initializes and returns a new CommentPart.
65
     * 
66
     * @param string $value
67
     * @return \ZBateson\MailMimeParser\Header\Part\CommentPart
68
     */
69
    public function newCommentPart($value)
70
    {
71
        return new CommentPart($value);
72
    }
73
    
74
    /**
75
     * Initializes and returns a new AddressPart.
76
     * 
77
     * @param string $name
78
     * @param string $email
79
     * @return \ZBateson\MailMimeParser\Header\Part\AddressPart
80
     */
81
    public function newAddressPart($name, $email)
82
    {
83
        return new AddressPart($name, $email);
84
    }
85
    
86
    /**
87
     * Initializes and returns a new AddressGroupPart
88
     * 
89
     * @param array $addresses
90
     * @param string $name
91
     * @return \ZBateson\MailMimeParser\Header\Part\AddressGroupPart
92
     */
93
    public function newAddressGroupPart(array $addresses, $name = '')
94
    {
95
        return new AddressGroupPart($addresses, $name);
96
    }
97
    
98
    /**
99
     * Initializes and returns a new DatePart
100
     * 
101
     * @param string $value
102
     * @return \ZBateson\MailMimeParser\Header\Part\DatePart
103
     */
104
    public function newDatePart($value)
105
    {
106
        return new DatePart($value);
107
    }
108
    
109
    /**
110
     * Initializes and returns a new ParameterPart.
111
     * 
112
     * @param string $name
113
     * @param string $value
114
     * @return \ZBateson\MailMimeParser\Header\Part\ParameterPart
115
     */
116
    public function newParameterPart($name, $value)
117
    {
118
        return new ParameterPart($name, $value);
119
    }
120
}
121