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

FinderService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A excluding() 0 6 1
A allFiles() 0 4 1
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