2023-03-16 13:00:05 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copyright 2023 Ad Aures
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2023-04-13 11:45:03 +00:00
|
|
|
if (! function_exists('add_suffix_to_path')) {
|
|
|
|
function change_file_path(string $path, string $suffix = '', ?string $newExtension = null): string
|
2023-03-16 13:00:05 +00:00
|
|
|
{
|
2023-04-13 11:45:03 +00:00
|
|
|
if ($newExtension === null) {
|
|
|
|
$newExtension = pathinfo($path, PATHINFO_EXTENSION);
|
2023-03-16 13:00:05 +00:00
|
|
|
}
|
|
|
|
|
2023-04-13 11:45:03 +00:00
|
|
|
return preg_replace('~\.[^.]+$~', '', $path) . $suffix . '.' . $newExtension;
|
2023-03-16 13:00:05 +00:00
|
|
|
}
|
|
|
|
}
|