Completed
Push — master ( b969a1...2f7e8d )
by Peter
02:18
created

MetaState   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 14
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __set_state() 0 9 2
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL, Commercial license.
5
 *
6
 * @package maslosoft/addendum
7
 * @licence AGPL, Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]> (Meta container, further improvements, bugfixes)
9
 * @copyright Copyright (c) Maslosoft (Meta container, further improvements, bugfixes)
10
 * @copyright Copyright (c) Jan Suchal (Original version, builder, parser)
11
 * @link https://maslosoft.com/addendum/ - maslosoft addendum
12
 * @link https://code.google.com/p/addendum/ - original addendum project
13
 */
14
15
namespace Maslosoft\Addendum\Traits;
16
17
/**
18
 * This trait can be used to implement `__set_state` magic method for meta containers.
19
 * Method `__set_state` is required for cache subsystem.
20
 *
21
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
22
 */
23
trait MetaState
24
{
25
26
	public static function __set_state($data)
27
	{
28
		$object = new static;
29
		foreach ($data as $name => $value)
30
		{
31
			$object->$name = $value;
32
		}
33
		return $object;
34
	}
35
36
}
37