PathCollection::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of ocubom/twig-svg-extension
5
 *
6
 * © Oscar Cubo Medina <https://ocubom.github.io>
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 Ocubom\Twig\Extension\Svg\Util;
13
14
use Symfony\Component\Filesystem\Path;
15
16
/**
17
 * @template-implements \IteratorAggregate<\SplFileInfo>
18
 */
19
class PathCollection implements \IteratorAggregate, \Stringable
20
{
21
    private array $searchPath = [];
22
23
    /**
24
     * Constructor.
25
     *
26
     * @param mixed ...$searchPath The paths where SVG files are located
27
     */
28 20
    public function __construct(...$searchPath)
29
    {
30 20
        foreach ($searchPath as $path) {
31 20
            $this->searchPath[] = new \SplFileInfo(Path::canonicalize($path));
32
        }
33
    }
34
35 20
    public function getIterator(): \Traversable
36
    {
37 20
        foreach ($this->searchPath as $path) {
38 20
            yield $path;
39
        }
40
    }
41
42 4
    public function __toString(): string
43
    {
44 4
        return implode(':', $this->searchPath);
45
    }
46
}
47