Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)
@param string $path A path.
@param string $suffix If the name component ends in suffix this will also be cut off.
@return string
421881
public static function mb_basename($path, $suffix = null) {
		$splited = preg_split('#/#', rtrim($path, '/ '));
		return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
	}
243904
public static function unique(string $prefix = '', string $suffix = ''): string
    {
        $unique = md5((string)mt_rand());
        if ($prefix !== '') {
            $unique = $prefix . $unique;
        }
        if ($suffix !== '') {
            $unique .= $suffix;
        }
        return $unique;
    }
306477
public static function rstrip($str, $suffix)
    {
        if (substr($str, -strlen($suffix)) == $suffix) {
            return substr($str, 0, -strlen($suffix));
        }
        return $str;
    }
104385
static public function suffixToContentType($suffix)
    {
        $types = self::bySuffix();
        return isset($types[$suffix]) ? $types[$suffix]['content-type'] : null;
    }
808377
public static function getAbsolutePath(string $path): string
    {
        $parts = \preg_split('~[/\\\\]+~', $path, 0, \PREG_SPLIT_NO_EMPTY);
        $absolutes = [];
        foreach ($parts as $part) {
            if ('.' === $part) {
                continue;
            }
            if ('..' === $part) {
                \array_pop($absolutes);
            } else {
                $absolutes[] = $part;
            }
        }

        /**
         * Allows to dereference char
         */
        $__FILE__ = \preg_replace('~^(([a-z0-9\-]+)://)~', '', __FILE__);// remove file protocols such as "phar://" etc.
        $prefix = $__FILE__[0] === \DIRECTORY_SEPARATOR ? \DIRECTORY_SEPARATOR : '';
        return $prefix . \implode(\DIRECTORY_SEPARATOR, $absolutes);
    }
989163
public static function asClassName(string $value, string $suffix = ''): string
    {
        $value = trim($value);
        $value = str_replace(['-', '_', '.', ':'], ' ', $value);
        $value = ucwords($value);
        $value = str_replace(' ', '', $value);
        $value = ucfirst($value);
        $value = self::addSuffix($value, $suffix);

        return $value;
    }
928176
protected function formatPath(string $path): string
    {
        $path = $this->filterPath($path)->withoutDotSegments();
        if ('' !== $this->base_uri->getAuthority() && '' !== $path->__toString()) {
            $path = $path->withLeadingSlash();
        }

        return (string) $path;
    }
831924
public function endsWith($suffix)
    {
        return $suffix === ''
        || $suffix === mb_substr(
            $this->contents,
            -strlen((string) $suffix),
            null,
            $this->encoding
        );
    }
5842
public function getId($suffix = null)
    {
        $id = class_basename(get_called_class());

        if ($this->alias != $this->defaultAlias) {
            $id .= '-' . $this->alias;
        }

        if ($suffix !== null) {
            $id .= '-' . $suffix;
        }

        return HtmlHelper::nameToId($id);
    }
256916
private static function pathToDotWithoutLastPart(string $path): string
    {
        $parts = explode('/', ltrim($path));

        array_pop($parts);

        return static::pathToDot(implode('/', $parts));
    }
691290
public static function prefix(string $path = ''): string
    {
        $prefix = config('platform.prefix');

        return Str::start($prefix.$path, '/');
    }
584690
public function setSuffix($suffix)
    {
        $this->_suffix = $suffix;
        $this->request->setPathInfo(implode('/', [$this->module->id, $suffix]));
    }
994633
public static function endsWith($str, $suffix)
    {
        return stripos($str, $suffix) === strlen($str) - strlen($suffix);
    }
852653
public static function getClassShortNameUnderscored(
        string $class,
        string $suffix = ''
    ): string {
        $classShortName = static::getClassShortName($class, $suffix);

        return StringUtils::underscore($classShortName);
    }
1276050
public static function getFilename($path)
    {
        $name = pathinfo($path, PATHINFO_FILENAME);

        $ext = pathinfo($path, PATHINFO_EXTENSION);

        if ($ext) {
            $name .= '.' . $ext;
        }

        return $name;
    }
1088995
public function getPrefix($suffix = null)
    {
        $prefix = $this->console->option('prefix');

        return $prefix ? $prefix.$suffix : null;
    }
915373
public function extension($path)
    {
        $index = strrpos($path, '.');
        return (false === $index) ? '' : substr($path, $index + 1);
    }