Passed
Push — 1.0.0 ( fcaf32...d3c3e6 )
by Zaahid
03:21
created

MimePartFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 46
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A newInstance() 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
namespace ZBateson\MailMimeParser\Message\Part;
8
9
use ZBateson\MailMimeParser\Header\HeaderFactory;
10
use ZBateson\MailMimeParser\Message\PartFilterFactory;
11
12
/**
13
 * Responsible for creating MimePart instances.
14
 *
15
 * @author Zaahid Bateson
16
 */
17
class MimePartFactory extends MessagePartFactory
18
{
19
    /**
20
     * @var \ZBateson\MailMimeParser\Header\HeaderFactory the HeaderFactory
21
     *      instance
22
     */
23
    protected $headerFactory;
24
    
25
    /**
26
     * @var \ZBateson\MailMimeParser\Header\HeaderFactory the PartFilterFactory
27
     *      instance
28
     */
29
    protected $partFilterFactory;
30
31
    /**
32
     * Creates a MimePartFactory instance with its dependencies.
33
     * 
34
     * @param PartStreamFilterManagerFactory $psf
35
     * @param HeaderFactory $hf
36
     * @param PartFilterFactory $pf
37
     */
38 1
    public function __construct(PartStreamFilterManagerFactory $psf, HeaderFactory $hf, PartFilterFactory $pf)
39
    {
40 1
        parent::__construct($psf);
41 1
        $this->headerFactory = $hf;
42 1
        $this->partFilterFactory = $pf;
0 ignored issues
show
Documentation Bug introduced by
It seems like $pf of type object<ZBateson\MailMime...sage\PartFilterFactory> is incompatible with the declared type object<ZBateson\MailMime...r\Header\HeaderFactory> of property $partFilterFactory.

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...
43 1
    }
44
45
    /**
46
     * Constructs a new MimePart object and returns it
47
     * 
48
     * @param string $messageObjectId
49
     * @param PartBuilder $partBuilder
50
     * @return \ZBateson\MailMimeParser\Message\Part\MimePart
51
     */
52 1
    public function newInstance($messageObjectId, PartBuilder $partBuilder)
53
    {
54 1
        return new MimePart(
55 1
            $this->headerFactory,
56 1
            $this->partFilterFactory,
0 ignored issues
show
Documentation introduced by
$this->partFilterFactory is of type object<ZBateson\MailMime...r\Header\HeaderFactory>, but the function expects a object<ZBateson\MailMime...sage\PartFilterFactory>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
57 1
            $messageObjectId,
58 1
            $partBuilder,
59 1
            $this->partStreamFilterManagerFactory->newInstance()
60 1
        );
61
    }
62
}
63