Passed
Push — master ( 2fd9d4...f7bb52 )
by Valentin
01:08
created

Names::onlyName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Spiral\Snapshotter\Helpers;
4
5
use Spiral\Files\FileManager;
6
7
class Names
8
{
9
    /** @var FileManager */
10
    private $files;
11
12
    /**
13
     * SnapshotService constructor.
14
     *
15
     * @param FileManager $files
16
     */
17
    public function __construct(FileManager $files)
18
    {
19
        $this->files = $files;
20
    }
21
22
    /**
23
     * @param string $path
24
     * @return string
25
     */
26
    public function onlyName(string $path): string
27
    {
28
        $path = $this->files->normalizePath($path);
29
30
        $pos = mb_strripos($path, '/');
31
32
        if ($pos !== false) {
33
            return mb_substr($path, $pos + 1);
34
        }
35
36
        return $path;
37
    }
38
}