Passed
Pull Request — master (#171)
by Zaahid
07:14 queued 03:53
created

MessagePartDecoratorTrait::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 1
c 1
b 0
f 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 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\Message;
8
9
/**
10
 * Simple decorator trait defining a constructor that accepts an IMessagePart,
11
 * sets $this->messagePart to the decorated part, and overrides __call to call
12
 * methods on $this->messagePart.
13
 *
14
 * @author Zaahid Bateson
15
 */
16
class MessagePartDecoratorTrait
17
{
18
    public function __construct(IMessagePart $messagePart)
19
    {
20
        $this->messagePart = $messagePart;
0 ignored issues
show
Bug Best Practice introduced by
The property messagePart does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
    }
22
23
    public function __call($method, array $args)
24
    {
25
        $result = call_user_func_array([$this->messagePart, $method], $args);
26
        return ($result === $this->messagePart) ? $this : $result;
27
    }
28
}
29