public static function extension($check, $extensions = ['gif', 'jpeg', 'png', 'jpg'])
    {
        if ($check instanceof UploadedFileInterface) {
            return static::extension($check->getClientFilename(), $extensions);
        }
        if (is_array($check)) {
            $check = isset($check['name']) ? $check['name'] : array_shift($check);

            return static::extension($check, $extensions);
        }
        $extension = strtolower(pathinfo($check, PATHINFO_EXTENSION));
        foreach ($extensions as $value) {
            if ($extension === strtolower($value)) {
                return true;
            }
        }

        return false;
    }
public static function extension($check, $extensions = ['gif', 'jpeg', 'png', 'jpg'])
    {
        if ($check instanceof UploadedFileInterface) {
            return static::extension($check->getClientFilename(), $extensions);
        }
        if (is_array($check)) {
            $check = isset($check['name']) ? $check['name'] : array_shift($check);

            return static::extension($check, $extensions);
        }
        $extension = strtolower(pathinfo($check, PATHINFO_EXTENSION));
        foreach ($extensions as $value) {
            if ($extension === strtolower($value)) {
                return true;
            }
        }

        return false;
    }
public static function extension ( $ check , $ extensions = [ 'gif' , 'jpeg' , 'png' , 'jpg' ] ) { if ( $ check instanceof UploadedFileInterface ) { return static :: extension ( $ check -> getClientFilename ( ) , $ extensions ) ; } if ( is_array ( $ check ) ) { $ check = isset ( $ check [ 'name' ] ) ? $ check [ 'name' ] : array_shift ( $ check ) ; return static :: extension ( $ check , $ extensions ) ; } $ extension = strtolower ( pathinfo ( $ check , PATHINFO_EXTENSION ) ) ; foreach ( $ extensions as $ value ) { if ( $ extension === strtolower ( $ value ) ) { return true ; } } return false ; }
Checks that value has a valid file extension.

@param string|array|\Psr\Http\Message\UploadedFileInterface $check Value to check
@param array $extensions file extensions to allow. By default extensions are 'gif', 'jpeg', 'png', 'jpg'
@return bool Success
Checks that value has a valid file extension .