Completed
Pull Request — master (#3)
by Valentin
14:15
created

Names::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
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
}