MessageFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 10 3
1
<?php
2
3
namespace RM\SMSender;
4
5
use ReflectionClass;
6
7 1
class MessageFactory implements IMessageFactory
8
{
9
	/**
10
	 * @var string
11
	 */
12
	public $class;
13
14
	/**
15
	 * List of methods with values for Message
16
	 * @var array
17
	 */
18
	public $params = [];
19
20
	/**
21
	 * @return IMessage
22
	 */
23
	public function create()
24
	{
25 1
		$message = new $this->class;
26 1
		foreach ($this->params as $method => $value) {
27 1
			if ((new ReflectionClass($message))->hasMethod($method)) {
28 1
				$message->$method($value);
29
			}
30
		}
31 1
		return $message;
32
	}
33
}
34