Completed
Push — master ( a694da...3962ba )
by Grzegorz
02:30
created

FilterCheck::isEnabledFilter()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 12
Code Lines 6

Duplication

Lines 6
Ratio 50 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 6
loc 12
rs 8.8571
cc 5
eloc 6
nc 5
nop 3
1
<?php
2
3
namespace ComicVine\Api\Filters;
4
5
/**
6
 * Trait FilterCheck
7
 *
8
 * @package grzgajda/comicvine-api
9
 * @author  Grzegorz Gajda <[email protected]>
10
 */
11
trait FilterCheck
12
{
13
    /**
14
     * Check if field $field is enabled for
15
     * making queries.
16
     *
17
     * @param string $field   Name of filters' field.
18
     * @param array  $filters Array of enabled filters for query.
19
     * @param mixed  $object  Return false or $this.
20
     *
21
     * @return $this
22
     */
23
    protected function isEnabledFilter($field, array $filters, $object = null)
24
    {
25 View Code Duplication
        if (array_key_exists($field, $filters) === false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
            return ($object === null) ? false : $object;
27
        }
28
29 View Code Duplication
        if ($filters[$field] === false) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
            return ($object === null) ? false : $object;
31
        }
32
33
        return true;
34
    }
35
}