ParserPartStreamContainerFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 15
c 0
b 0
f 0
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A newInstance() 0 8 1
A __construct() 0 10 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
8
namespace ZBateson\MailMimeParser\Parser\Part;
9
10
use Psr\Log\LoggerInterface;
11
use ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxy;
12
use ZBateson\MailMimeParser\Stream\StreamFactory;
13
use ZBateson\MbWrapper\MbWrapper;
14
15
/**
16
 * Creates ParserPartStreamContainer instances.
17
 *
18
 * @author Zaahid Bateson
19
 */
20
class ParserPartStreamContainerFactory
21
{
22
    protected LoggerInterface $logger;
23
24
    protected StreamFactory $streamFactory;
25
26
    protected MbWrapper $mbWrapper;
27
28
    protected bool $throwExceptionReadingPartContentFromUnsupportedCharsets;
29
30 2
    public function __construct(
31
        LoggerInterface $logger,
32
        StreamFactory $streamFactory,
33
        MbWrapper $mbWrapper,
34
        bool $throwExceptionReadingPartContentFromUnsupportedCharsets
35
    ) {
36 2
        $this->logger = $logger;
37 2
        $this->streamFactory = $streamFactory;
38 2
        $this->mbWrapper = $mbWrapper;
39 2
        $this->throwExceptionReadingPartContentFromUnsupportedCharsets = $throwExceptionReadingPartContentFromUnsupportedCharsets;
40
    }
41
42 107
    public function newInstance(ParserPartProxy $parserProxy) : ParserPartStreamContainer
43
    {
44 107
        return new ParserPartStreamContainer(
45 107
            $this->logger,
46 107
            $this->streamFactory,
47 107
            $this->mbWrapper,
48 107
            $this->throwExceptionReadingPartContentFromUnsupportedCharsets,
49 107
            $parserProxy
50 107
        );
51
    }
52
}
53