Completed
Push — master ( 7d6c96...5af7de )
by Peter
05:54
created

IndexDecorator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A read() 0 10 3
A write() 0 4 1
1
<?php
2
3
namespace Maslosoft\Manganel\Decorators;
4
5
use Maslosoft\Mangan\Interfaces\Decorators\Model\ModelDecoratorInterface;
6
use Maslosoft\Mangan\Interfaces\Transformators\TransformatorInterface;
7
use Maslosoft\Manganel\Interfaces\IndexAwareInterface;
8
9
/**
10
 * IndexDecorator
11
 *
12
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
13
 */
14
class IndexDecorator implements ModelDecoratorInterface
15
{
16
17
	/**
18
	 * Key used for score
19
	 */
20
	const Key = '__index';
21
22 28
	public function read($model, &$dbValues, $transformatorClass = TransformatorInterface::class)
23
	{
24 28
		if ($model instanceof IndexAwareInterface)
25
		{
26 1
			if (array_key_exists(self::Key, $dbValues))
27
			{
28 1
				$model->setIndex($dbValues[self::Key]);
29
			}
30
		}
31 28
	}
32
33 50
	public function write($model, &$dbValues, $transformatorClass = TransformatorInterface::class)
34
	{
35
36 50
	}
37
38
}
39