ItemProperty   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 16 5
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw\Draw\LoopHelper;
12
13
use ArrayObject;
14
use WebinoDraw\Exception\InvalidLoopHelperOptionException;
15
16
/**
17
 *
18
 */
19
class ItemProperty implements HelperInterface
20
{
21
    /**
22
     * {@inheritDoc}
23
     * @throws InvalidLoopHelperOptionException
24
     */
25
    public function __invoke(ArrayObject $loopArgument, array $options)
26
    {
27
        if (empty($options['property'])) {
28
            throw new InvalidLoopHelperOptionException('property', $loopArgument['spec']);
29
        }
30
        if (empty($options['value'])) {
31
            throw new InvalidLoopHelperOptionException('value', $loopArgument['spec']);
32
        }
33
        if (empty($options['each'])) {
34
            throw new InvalidLoopHelperOptionException('each', $loopArgument['spec']);
35
        }
36
37
        $loopArgument['item'][$options['property']] = ($loopArgument['index'] % $options['each'] === 0)
38
                                                    ? $options['value']
39
                                                    : '';
40
    }
41
}
42