IntegerArray::filterValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * Spiral, Core Components
4
 *
5
 * @author Wolfy-J
6
 */
7
8
namespace Spiral\ODM\Accessors;
9
10
/**
11
 * Allows to store only integer values.
12
 *
13
 * Attention, array will be saved as one big $set operation in case when multiple atomic
14
 * operations applied to it (not supported by Mongo).
15
 */
16
class IntegerArray extends AbstractArray
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    protected function filterValue($value)
22
    {
23
        if (!is_numeric($value)) {
24
            return null;
25
        }
26
27
        return intval($value);
28
    }
29
}