FileHelper::getExtension()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php namespace Modules\Media\Helpers;
2
3
use Illuminate\Support\Str;
4
5
class FileHelper
6
{
7
    public static function slug($name)
8
    {
9
        $extension = self::getExtension($name);
10
        $name = str_replace($extension, '', $name);
11
12
        $name = Str::slug($name);
13
14
        return $name . $extension;
15
    }
16
17
    /**
18
     * Get the extension from the given name
19
     * @param $name
20
     * @return string
21
     */
22
    private static function getExtension($name)
23
    {
24
        return strtolower(substr($name, strrpos($name, '.')));
25
    }
26
}
27