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.

Finder   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 1
dl 0
loc 74
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 3
A canRead() 0 12 2
A getFinder() 0 4 1
A setFinder() 0 6 1
1
<?php
2
/**
3
 * Finder.php
4
 *
5
 * @package         ProjectVersioner
6
 * @subpackage      Reader
7
 */
8
9
namespace Naneau\ProjectVersioner\Reader\Finder;
10
11
use Naneau\ProjectVersioner\ReaderInterface;
12
13
use Symfony\Component\Finder\Finder as SfFinder;
14
15
/**
16
 * Finder
17
 *
18
 * Base class for finder based readers
19
 *
20
 * @category        Naneau
21
 * @package         ProjectVersioner
22
 * @subpackage      Reader
23
 */
24
abstract class Finder implements ReaderInterface
25
{
26
    /**
27
     * the finder
28
     *
29
     * @var SfFinder
30
     */
31
    private $finder;
32
33
    /**
34
     * Constructor
35
     *
36
     * @param  string   $name   limiting names
37
     * @param  SfFinder $finder
38
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
39
     **/
40
    public function __construct($name = null, SfFinder $finder = null)
41
    {
42
        // Create finder if not given
43
        if ($finder === null) {
44
            $finder = new SfFinder;
45
        }
46
47
        // Set name if given
48
        if (!empty($name)) {
49
            $finder->name($name);
50
        }
51
52
        // Sort by name
53
        $finder->sortByName();
54
55
        // Set the finder
56
        $this->setFinder($finder);
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     **/
62
    public function canRead($directory)
63
    {
64
        // Update finder directory
65
        $this->getFinder()->in($directory);
66
67
        // If at least one file/dir can be found, assume we can read
68
        foreach ($this->getFinder() as $file) {
69
            return true;
70
        }
71
72
        return false;
73
    }
74
75
    /**
76
     * Get the finder
77
     *
78
     * @return SfFinder
79
     */
80
    public function getFinder()
81
    {
82
        return $this->finder;
83
    }
84
85
    /**
86
     * Set the finder
87
     *
88
     * @param  SfFinder $finder
89
     * @return SfFinder
90
     */
91
    public function setFinder(SfFinder $finder)
92
    {
93
        $this->finder = $finder;
94
95
        return $this;
96
    }
97
}
98