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

Names   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 32
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A onlyName() 0 12 2
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
}