Completed
Push — 2.0 ( b08834...8cb3f2 )
by Nicolas
06:12
created

FinderService::allFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Modules\Page\Services;
4
5
use Symfony\Component\Finder\Finder;
6
7
class FinderService
8
{
9
    protected $filesystem;
10
11
    public function __construct()
12
    {
13
        $this->filesystem = Finder::create()->files();
14
    }
15
16
    /**
17
     * @param  array $excludes
18
     *
19
     * @return $this
20
     */
21
    public function excluding($excludes)
22
    {
23
        $this->filesystem = $this->filesystem->exclude($excludes);
24
25
        return $this;
26
    }
27
28
    /**
29
     * Get all of the files from the given directory (recursive).
30
     *
31
     * @param  string $directory
32
     * @param  bool $hidden
33
     *
34
     * @return array
35
     */
36
    public function allFiles($directory, $hidden = false)
37
    {
38
        return iterator_to_array($this->filesystem->ignoreDotFiles(! $hidden)->in($directory), false);
39
    }
40
}
41