Passed
Pull Request — master (#171)
by Zaahid
03:23
created

MessagePartDecoratorTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 4
c 1
b 0
f 1
dl 0
loc 11
ccs 0
cts 6
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 4 2
A __construct() 0 3 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;
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