Completed
Push — 1.0.0 ( 608796...a0ab23 )
by Zaahid
04:48
created

PartFactoryService::getMessageFactory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 9.4285
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 ZBateson\MailMimeParser\Stream\StreamDecoratorFactory;
10
use ZBateson\MailMimeParser\Header\HeaderFactory;
11
use ZBateson\MailMimeParser\Message\MessageFactory;
12
use ZBateson\MailMimeParser\Message\PartFilterFactory;
13
14
/**
15
 * Responsible for creating singleton instances of MessagePartFactory and its
16
 * subclasses.
17
 *
18
 * @author Zaahid Bateson
19
 */
20
class PartFactoryService
21
{
22
    /**
23
     * @var \ZBateson\MailMimeParser\Header\HeaderFactory the HeaderFactory
24
     *      object used for created headers
25
     */
26
    protected $headerFactory;
27
    
28
    /**
29
     * @var \ZBateson\MailMimeParser\Header\HeaderFactory the PartFilterFactory
30
     *      instance
31
     */
32
    protected $partFilterFactory;
33
    
34
    /**
35
     * @var PartStreamFilterManagerFactory the PartStreamFilterManagerFactory
36
     *      instance
37
     */
38
    protected $partStreamFilterManagerFactory;
39
40
    /**
41
     * @var StreamDecoratorFactory the StreamDecoratorFactory instance
42
     */
43
    protected $streamDecoratorFactory;
44
    
45
    /**
46
     * Sets up dependencies.
47
     * 
48
     * @param HeaderFactory $headerFactory
49
     * @param PartFilterFactory $partFilterFactory
50
     * @param StreamDecoratorFactory $streamDecoratorFactory
51
     * @param PartStreamFilterManagerFactory $partStreamFilterManagerFactory
52
     */
53
    public function __construct(
54
        HeaderFactory $headerFactory,
55
        PartFilterFactory $partFilterFactory,
56
        StreamDecoratorFactory $streamDecoratorFactory,
57
        PartStreamFilterManagerFactory $partStreamFilterManagerFactory
58
    ) {
59
        $this->headerFactory = $headerFactory;
60
        $this->partFilterFactory = $partFilterFactory;
0 ignored issues
show
Documentation Bug introduced by
It seems like $partFilterFactory of type ZBateson\MailMimeParser\Message\PartFilterFactory is incompatible with the declared type ZBateson\MailMimeParser\Header\HeaderFactory of property $partFilterFactory.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
61
        $this->streamDecoratorFactory = $streamDecoratorFactory;
62
        $this->partStreamFilterManagerFactory = $partStreamFilterManagerFactory;
63
    }
64
65
    /**
66
     * Returns the MessageFactory singleton instance.
67
     * 
68
     * @return MessageFactory
69
     */
70 1
    public function getMessageFactory()
71
    {
72 1
        return MessageFactory::getInstance(
73 1
            $this->streamDecoratorFactory,
74 1
            $this->partStreamFilterManagerFactory,
75 1
            $this->headerFactory,
76 1
            $this->partFilterFactory
0 ignored issues
show
Bug introduced by
$this->partFilterFactory of type ZBateson\MailMimeParser\Header\HeaderFactory is incompatible with the type null|ZBateson\MailMimePa...ssage\PartFilterFactory expected by parameter $pf of ZBateson\MailMimeParser\...tFactory::getInstance(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

76
            /** @scrutinizer ignore-type */ $this->partFilterFactory
Loading history...
77
        );
78
    }
79
    
80
    /**
81
     * Returns the MimePartFactory singleton instance.
82
     * 
83
     * @return MimePartFactory
84
     */
85 1
    public function getMimePartFactory()
86
    {
87 1
        return MimePartFactory::getInstance(
88 1
            $this->streamDecoratorFactory,
89 1
            $this->partStreamFilterManagerFactory,
90 1
            $this->headerFactory,
91 1
            $this->partFilterFactory
0 ignored issues
show
Bug introduced by
$this->partFilterFactory of type ZBateson\MailMimeParser\Header\HeaderFactory is incompatible with the type null|ZBateson\MailMimePa...ssage\PartFilterFactory expected by parameter $pf of ZBateson\MailMimeParser\...tFactory::getInstance(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

91
            /** @scrutinizer ignore-type */ $this->partFilterFactory
Loading history...
92
        );
93
    }
94
    
95
    /**
96
     * Returns the NonMimePartFactory singleton instance.
97
     * 
98
     * @return NonMimePartFactory
99
     */
100 1
    public function getNonMimePartFactory()
101
    {
102 1
        return NonMimePartFactory::getInstance(
103 1
            $this->streamDecoratorFactory,
104 1
            $this->partStreamFilterManagerFactory
105
        );
106
    }
107
    
108
    /**
109
     * Returns the UUEncodedPartFactory singleton instance.
110
     * 
111
     * @return UUEncodedPartFactory
112
     */
113 1
    public function getUUEncodedPartFactory()
114
    {
115 1
        return UUEncodedPartFactory::getInstance(
116 1
            $this->streamDecoratorFactory,
117 1
            $this->partStreamFilterManagerFactory
118
        );
119
    }
120
}
121