ShortName::shortname()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Packagist Mirror.
7
 *
8
 * For the full license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Webs\Mirror;
13
14
/**
15
 * Trait to shortname of package.
16
 *
17
 * @author Webysther Nunes <[email protected]>
18
 */
19
trait ShortName
20
{
21
    /**
22
     * Find hash and replace by *.
23
     *
24
     * @param string $name Name of provider or package
25
     *
26
     * @return string Shortname
27
     */
28 1
    protected function shortname(string $name):string
29
    {
30 1
        return str_replace('*', '$*', preg_replace('/\$(\w*)/', '*', $name));
31
    }
32
}
33