SubSet   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 18
rs 10
c 0
b 0
f 0
ccs 0
cts 6
cp 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getList() 0 8 2
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
namespace Xoops\Core\Lists;
13
14
/**
15
 * SubSet - return a list which is a subset of another list
16
 *
17
 * @category  Xoops\Core\Lists\SubSet
18
 * @package   Xoops\Core
19
 * @author    Richard Griffith <[email protected]>
20
 * @copyright 2015 XOOPS Project (http://xoops.org)/
21
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
22
 * @link      http://xoops.org
23
 */
24
class SubSet extends ListAbstract
25
{
26
    /**
27
     * return a subset of a list
28
     *
29
     * @param array $list associative list array
30
     * @param array $keys indexed array of keys to keep
31
     *
32
     * @return array
33
     */
34
    public static function getList($list = [], $keys = null)
35
    {
36
        if (is_array($keys)) {
37
            $keys = array_flip($keys);
38
            $subset = array_intersect_key($list, $keys);
39
            return $subset;
40
        }
41
        return($list);
42
    }
43
}
44