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

MimeParserFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 49
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A newInstance() 0 8 1
A __construct() 0 10 1
A canParse() 0 4 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\Parser;
8
9
use ZBateson\MailMimeParser\Message\PartHeaderContainer;
10
use ZBateson\MailMimeParser\Message\Factory\PartHeaderContainerFactory;
11
use ZBateson\MailMimeParser\Parser\Proxy\ParserMimePartFactory;
12
13
/**
14
 * Description of MimeParserFactory
15
 *
16
 * @author Zaahid Bateson
17
 */
18
class MimeParserFactory implements IParserFactory
19
{
20
    /**
21
     * @var PartHeaderContainerFactory
22
     */
23
    protected $partHeaderContainerFactory;
24
25
    /**
26
     * @var PartBuilderFactory
27
     */
28
    protected $partBuilderFactory;
29
30
    /**
31
     * @var HeaderParser
32
     */
33
    protected $headerParser;
34
35
    /**
36
     * @var ParsedMimePartFactory for ParsedMimePart objects
0 ignored issues
show
Bug introduced by
The type ZBateson\MailMimeParser\...r\ParsedMimePartFactory 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...
37
     */
38
    protected $parserMimePartFactory;
39
40
    public function __construct(
41
        PartBuilderFactory $pbf,
42
        PartHeaderContainerFactory $phcf,
43
        HeaderParser $hp,
44
        ParserMimePartFactory $f
45
    ) {
46
        $this->partBuilderFactory = $pbf;
47
        $this->partHeaderContainerFactory = $phcf;
48
        $this->headerParser = $hp;
49
        $this->parserMimePartFactory = $f;
0 ignored issues
show
Documentation Bug introduced by
It seems like $f of type ZBateson\MailMimeParser\...y\ParserMimePartFactory is incompatible with the declared type ZBateson\MailMimeParser\...r\ParsedMimePartFactory of property $parserMimePartFactory.

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...
50
    }
51
52
    public function newInstance()
53
    {
54
        return new MimeParser(
55
            $this->partBuilderFactory,
56
            $this->partHeaderContainerFactory,
57
            $this->headerParser,
58
            $this->parserMimePartFactory,
59
            $this
60
        );
61
    }
62
63
    public function canParse(PartHeaderContainer $messageHeaders)
64
    {
65
        return ($messageHeaders->exists('Content-Type') ||
66
            $messageHeaders->exists('Mime-Version'));
67
    }
68
}
69