ArrayProcessor   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 62
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0
wmc 8
lcom 0
cbo 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A field() 0 4 3
A offset() 0 4 2
A slice() 0 4 1
A count() 0 4 1
A reverse() 0 4 1
1
<?php
2
3
namespace mav3rick177\RapidPagination\Base;
4
5
class ArrayProcessor extends AbstractProcessor
6
{
7
    /**
8
     * Return comparable value from a row.
9
     *
10
     * @param  mixed      $row
11
     * @param  string     $column
12
     * @return int|string
13
     */
14
    protected function field($row, $column)
15
    {
16
        return is_object($row) && !$row instanceof \ArrayAccess ? $row->$column : $row[$column];
17
    }
18
19
    /**
20
     * Return the n-th element of collection.
21
     * Must return null if not exists.
22
     *
23
     * @param  array $rows
24
     * @param  int   $offset
25
     * @return mixed
26
     */
27
    protected function offset($rows, $offset)
28
    {
29
        return isset($rows[$offset]) ? $rows[$offset] : null;
30
    }
31
32
    /**
33
     * Slice rows, like PHP function array_slice().
34
     *
35
     * @param  array    $rows
36
     * @param  int      $offset
37
     * @param  null|int $length
38
     * @return array
39
     */
40
    protected function slice($rows, $offset, $length = null)
41
    {
42
        return array_slice($rows, $offset, $length);
43
    }
44
45
    /**
46
     * Count rows, like PHP function count().
47
     *
48
     * @param  array $rows
49
     * @return int
50
     */
51
    protected function count($rows)
52
    {
53
        return count($rows);
54
    }
55
56
    /**
57
     * Reverse rows, like PHP function array_reverse().
58
     *
59
     * @param  array $rows
60
     * @return array
61
     */
62
    protected function reverse($rows)
63
    {
64
        return array_reverse($rows);
65
    }
66
}
67