GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

FilesTrait::files()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 8
rs 9.4286
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace Pipes\Filter;
4
5
trait FilesTrait
6
{
7
    /**
8
     * Iterates files
9
     * (internally uses \GlobIterator).
10
     *
11
     * <code>
12
     * $files = p->files('/tmp/*.txt');
13
     * foreach ($files as $f) {
14
     *     echo $f .PHP_EOL;
15
     * }
16
     * </code>
17
     *
18
     * Use true to get a SplFileInfo object for each file:
19
     * <code>
20
     * $files = p->files('/tmp/*.txt');
21
     * </code>
22
     *
23
     * You can also pass any GlobIterator or FilesystemIterator flag
24
     *
25
     * <code>
26
     * $files = p->files('/tmp/*.txt', \FilesystemIterator::FOLLOW_SYMLINKS);
27
     * </code>
28
     *
29
     * You are incoraged to download and use Symfony Finder for any advanced need:
30
     *
31
     * <code>
32
     * $finder = new Finder();
33
     * $iterator = $finder
34
     *     ->files()
35
     *     ->name('*.php')
36
     *     ->depth(0)
37
     *     ->size('>= 1K')
38
     *     ->in(__DIR__);
39
     *
40
     * // then you can use your new iterator with pipes :)
41
     * p($iterator)->each(function () {
42
     *     //... do stuff
43
     * });
44
     *
45
     * </code>
46
     *
47
     * @param string $path  any file wildcard (ie:/tmp/*.txt). Use the full path!
48
     * @param int    $flags any GlobIterator or FilesystemIterator flag
49
     *
50
     * @return \Pipes\Pipe
51
     */
52
    public function files($path, $flags = \GlobIterator::CURRENT_AS_PATHNAME)
53
    {
54
        if ($flags === true) {
55
            $flags = 0;
56
        }
57
58
        return new static (new \GlobIterator($path, $flags));
0 ignored issues
show
Unused Code introduced by
The call to FilesTrait::__construct() has too many arguments starting with new \GlobIterator($path, $flags).

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...
59
    }
60
}
61