ParserPartStreamContainerFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 4
crap 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