Completed
Push — master ( c4431a...dfa02b )
by Zoltán
02:49
created

FilterableCollectionTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 12
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A filter() 0 5 1
1
<?php namespace BuildR\Collection\Collection;
2
3
use BuildR\Collection\Utils\ArrayFilter;
4
5
/**
6
 * Trait for filterable collections
7
 *
8
 * BuildR PHP Framework
9
 *
10
 * @author Zoltán Borsos <[email protected]>
11
 * @package Collection
12
 * @subpackage Collection
13
 *
14
 * @copyright    Copyright 2015, Zoltán Borsos.
15
 * @license      https://github.com/Zolli/BuildR/blob/master/LICENSE.md
16
 * @link         https://github.com/Zolli/BuildR
17
 *
18
 * @codeCoverageIgnore
19
 */
20
trait FilterableCollectionTrait {
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function filter(callable $filter) {
26
        $result = ArrayFilter::execute($this->data, $filter);
0 ignored issues
show
Bug introduced by
The property data does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
27
28
        return new self($result);
0 ignored issues
show
Unused Code introduced by
The call to FilterableCollectionTrait::__construct() has too many arguments starting with $result.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
29
    }
30
31
}