OptionsFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A filterOptions() 0 9 2
1
<?php
2
namespace Wheedle;
3
4
/**
5
 * A trait to handle the filtering of query string params
6
 *
7
 * @author Matt Frost <[email protected]
8
 * @license MIT http://opensource.org/licenses/MIT
9
 * @package Wheedle
10
 */
11
trait OptionsFilter
12
{
13
    /**
14
     * Method to filter out any unavailable parameters
15
     *
16
     * @param Array $availableOptions An array of available parameters
17
     * @param Array $options An array of the provided parameters
18
     * @return Arrary
19
     */
20
    public function filterOptions($availableOptions, $options)
21
    {
22
        array_walk($options, function ($value, $key) use ($availableOptions, &$options) {
23
            if (!in_array($key, $availableOptions)) {
24
                unset($options[$key]);
25
            }
26
        });
27
        return $options;
28
    }
29
}
30