FilesystemResourceCollection   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
c 1
b 1
f 0
lcom 0
cbo 2
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFilesystemPaths() 0 14 2
1
<?php
2
3
/*
4
 * This file is part of the puli/repository package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Repository\Resource\Collection;
13
14
use Puli\Repository\Api\Resource\FilesystemResource;
15
use Puli\Repository\Api\Resource\PuliResource;
16
17
/**
18
 * A collection of resources on the filesystem.
19
 *
20
 * The resource collection contains the additional method
21
 * {@link getFilesystemPaths()} for batch collecting the filesystem paths of all
22
 * contained resources.
23
 *
24
 * @since  1.0
25
 *
26
 * @author Bernhard Schussek <[email protected]>
27
 */
28
class FilesystemResourceCollection extends ArrayResourceCollection
29
{
30
    /**
31
     * Returns the filesystem paths of all contained resources.
32
     *
33
     * The paths are returned in order of the resources. Resources that are not
34
     * on the filesystem are ignored and not contained in the output.
35
     *
36
     * @return string[] The filesystem paths.
37
     */
38 3
    public function getFilesystemPaths()
39
    {
40 3
        return array_map(
41
            function (FilesystemResource $resource) {
42 3
                return $resource->getFilesystemPath();
43 3
            },
44
            array_filter(
45 3
                $this->toArray(),
46 3
                function (PuliResource $r) {
47 3
                    return $r instanceof FilesystemResource && null !== $r->getFilesystemPath();
48 3
                }
49
            )
50
        );
51
    }
52
}
53