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

NonMimeParserFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
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\Parser\Proxy\ParserUUEncodedPartFactory;
10
use ZBateson\MailMimeParser\Message\PartHeaderContainer;
11
12
/**
13
 * Description of NonMimeParserFactory
14
 *
15
 * @author Zaahid Bateson
16
 */
17
class NonMimeParserFactory implements IParserFactory
18
{
19
    /**
20
     * @var PartBuilderFactory
21
     */
22
    protected $partBuilderFactory;
23
24
    /**
25
     * @var ParserUUEncodedPartFactory for ParsedMimePart objects
26
     */
27
    protected $parserUuEncodedPartFactory;
28
29
    public function __construct(
30
        PartBuilderFactory $pbf,
31
        ParserUUEncodedPartFactory $f
32
    ) {
33
        $this->partBuilderFactory = $pbf;
34
        $this->parserUuEncodedPartFactory = $f;
35
    }
36
37
    public function newInstance()
38
    {
39
        return new NonMimeParser(
40
            $this->partBuilderFactory,
41
            $this->parserUuEncodedPartFactory,
42
            $this
43
        );
44
    }
45
46
    public function canParse(PartHeaderContainer $messageHeaders)
47
    {
48
        return (!$messageHeaders->exists('Content-Type') &&
49
            !$messageHeaders->exists('Mime-Version'));
50
    }
51
}
52