KeysTrait::keys()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 0
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 3
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Zicht Online <http://zicht.nl>
4
 */
5
6
namespace Zicht\Itertools\lib\Traits;
7
8
trait KeysTrait
9
{
10
    /**
11
     * Returns an array with keys from this iterator
12
     *
13
     * @return array
14
     */
15 22
    public function keys()
16
    {
17 22
        $keys = [];
18 22
        if ($this instanceof \Traversable) {
19 22
            foreach ($this as $key => $value) {
20 16
                $keys [] = $key;
21
            }
22
        }
23 22
        return $keys;
24
    }
25
}
26