Test Failed
Push — 2.0 ( 4d4d2f...3431b8 )
by Zaahid
04:28
created

ParserUUEncodedPartFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 55
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setParserFactory() 0 3 1
A newInstance() 0 19 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\Parser\Proxy;
8
9
use ZBateson\MailMimeParser\Message\UUEncodedPart;
10
use ZBateson\MailMimeParser\Parser\IParserFactory;
11
use ZBateson\MailMimeParser\Parser\PartBuilder;
12
use ZBateson\MailMimeParser\Parser\Part\ParsedPartStreamContainerFactory;
13
use ZBateson\MailMimeParser\Stream\StreamFactory;
14
15
/**
16
 * Responsible for creating ParsedUUEncodedPart instances.
17
 *
18
 * @author Zaahid Bateson
19
 */
20
class ParserUUEncodedPartFactory
21
{
22
    /**
23
     * @var StreamFactory the StreamFactory instance
24
     */
25
    protected $streamFactory;
26
27
    /**
28
     * @var ParsedPartStreamContainerFactory
29
     */
30
    protected $parsedPartStreamContainerFactory;
31
32
    /**
33
     * @var IParserFactory
34
     */
35
    protected $parserFactory;
36
37
    public function __construct(
38
        StreamFactory $sdf,
39
        ParsedPartStreamContainerFactory $parsedPartStreamContainerFactory
40
    ) {
41
        $this->streamFactory = $sdf;
42
        $this->parsedPartStreamContainerFactory = $parsedPartStreamContainerFactory;
43
    }
44
45
    public function setParserFactory(IParserFactory $parserFactory)
46
    {
47
        $this->parserFactory = $parserFactory;
48
    }
49
50
    /**
51
     * Constructs a new IUUEncodedPart object and returns it
52
     * 
53
     * @param PartBuilder $partBuilder
54
     * @return IUUEncodedPart
0 ignored issues
show
Bug introduced by
The type ZBateson\MailMimeParser\...er\Proxy\IUUEncodedPart was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
55
     */
56
    public function newInstance(PartBuilder $partBuilder, $mode, $filename, ParserMimePartProxy $parent)
57
    {
58
        $parserProxy = new ParserUUEncodedPartProxy($partBuilder, $parent->getParser(), $parent);
59
        $streamContainer = $this->parsedPartStreamContainerFactory->newInstance($parserProxy);
60
61
        $part = new UUEncodedPart(
62
            $mode,
63
            $filename,
64
            $parent->getPart(),
65
            $streamContainer
66
        );
67
        $parserProxy->setPart($part);
68
        $parserProxy->setParsedPartStreamContainer($streamContainer);
69
70
        $streamContainer->setStream($this->streamFactory->newMessagePartStream($part));
71
        $part->attach($streamContainer);
72
73
        $parent->addChild($parserProxy);
74
        return $part;
75
    }
76
}
77