DbCommandModel   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 24
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 19 4
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL or Commercial license.
5
 *
6
 * @package maslosoft/mangan
7
 * @licence AGPL or Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]>
9
 * @copyright Copyright (c) Maslosoft
10
 * @copyright Copyright (c) Others as mentioned in code
11
 * @link https://maslosoft.com/mangan/
12
 */
13
14
namespace Maslosoft\Mangan\Model\Command;
15
16
use ReflectionClass;
17
18
/**
19
 * DbModel
20
 *
21
 * @internal This is base class for database commands models
22
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
23
 */
24
abstract class DbCommandModel
25
{
26
27 2
	public function toArray($except = [])
28
	{
29 2
		$result = [];
30 2
		foreach ((new ReflectionClass($this))->getProperties() as $info)
31
		{
32 2
			$name = $info->name;
33 2
			if (in_array($name, $except))
34
			{
35 2
				continue;
36
			}
37 2
			$value = $this->$name;
38 2
			if ($value instanceof self)
39
			{
40 1
				$value = $value->toArray();
41
			}
42 2
			$result[$name] = $value;
43
		}
44 2
		return $result;
45
	}
46
47
}
48