ScrollDecorator   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A decorate() 0 14 5
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\QueryBuilder;
14
15
use Maslosoft\Manganel\Interfaces\QueryBuilder\BodyDecoratorInterface;
16
use Maslosoft\Manganel\SearchCriteria;
17
18
/**
19
 * ScrollDecorator
20
 *
21
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
22
 */
23
class ScrollDecorator implements BodyDecoratorInterface
24
{
25
26 32
	public function decorate(&$body, SearchCriteria $criteria)
27
	{
28 32
		if ($criteria->getLimit() || $criteria->getOffset())
29
		{
30 17
			if (is_int($criteria->getOffset()))
31
			{
32 14
				$body['from'] = $criteria->getOffset();
33
			}
34 17
			if (is_int($criteria->getLimit()))
35
			{
36 17
				$body['size'] = $criteria->getLimit();
37
			}
38
		}
39 32
	}
40
41
}
42