FilenameRecursiveTreeIterator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A current() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of Cecil.
5
 *
6
 * (c) Arnaud Ligny <[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
declare(strict_types=1);
13
14
namespace Cecil\Command\ShowContent;
15
16
use RecursiveTreeIterator;
17
18
/**
19
 * FilenameRecursiveTreeIterator class.
20
 *
21
 * This class extends RecursiveTreeIterator to modify the current method
22
 * so that it returns only the filename of the current item, instead of the full path.
23
 * It is useful for displaying a tree structure of files with just their names.
24
 */
25
class FilenameRecursiveTreeIterator extends RecursiveTreeIterator
26
{
27
    /**
28
     * @return mixed
29
     */
30
    public function current(): mixed
31
    {
32
        return str_replace(
33
            (string) $this->getInnerIterator()->current(),
34
            substr(strrchr((string) $this->getInnerIterator()->current(), DIRECTORY_SEPARATOR), 1),
35
            parent::current()
36
        );
37
    }
38
}
39