Completed
Pull Request — master (#121)
by Vladimir
02:51 queued 01:05
created

FileExplorerMatcher   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
ccs 4
cts 5
cp 0.8
wmc 2
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A modifiedAfter() 0 12 2
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Filesystem;
9
10
abstract class FileExplorerMatcher
11
{
12
    /**
13
     * Return a matcher callable for files that have been modified after a certain timestamp.
14
     *
15
     * @param \DateTime $time
16
     *
17
     * @throws \Exception
18
     *
19
     * @return \Closure
20
     */
21
    public static function modifiedAfter(\DateTime $time)
22
    {
23 1
        return function ($file) use ($time) {
24
            /** @var File|Folder $file */
25
26 1
            if ($file instanceof Folder) {
27
                return true;
28
            }
29
30 1
            return $file->getLastModified() > $time->getTimestamp();
31 1
        };
32
    }
33
}
34