ScoreDecorator::read()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 3
crap 3
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL-3.0-only, proprietary` license[s].
5
 *
6
 * @package maslosoft/manganel
7
 * @license AGPL-3.0-only, proprietary
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/manganel/
11
 */
12
13
namespace Maslosoft\Manganel\Decorators;
14
15
use Maslosoft\Mangan\Interfaces\Decorators\Model\ModelDecoratorInterface;
16
use Maslosoft\Mangan\Interfaces\Transformators\TransformatorInterface;
17
use Maslosoft\Manganel\Interfaces\ScoreAwareInterface;
18
19
/**
20
 * ScoreDecorator
21
 *
22
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
23
 */
24
class ScoreDecorator implements ModelDecoratorInterface
25
{
26
27
	/**
28
	 * Key used for score
29
	 */
30
	const Key = '__score';
31
32 24
	public function read($model, &$dbValues, $transformatorClass = TransformatorInterface::class)
33
	{
34 24
		if ($model instanceof ScoreAwareInterface)
35
		{
36 14
			if (array_key_exists(self::Key, $dbValues))
37
			{
38 11
				$model->setScore(floatval($dbValues[self::Key]));
39
			}
40
		}
41 24
	}
42
43 53
	public function write($model, &$dbValues, $transformatorClass = TransformatorInterface::class)
44
	{
45
46 53
	}
47
48
}
49