2022-12-09 15:04:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copyright 2021 Ad Aures
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Modules\Analytics;
|
|
|
|
|
|
|
|
use App\Entities\Episode;
|
|
|
|
|
|
|
|
class OP3
|
|
|
|
{
|
|
|
|
protected string $host;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array<string, string> $config
|
|
|
|
*/
|
|
|
|
public function __construct(array $config)
|
|
|
|
{
|
|
|
|
$this->host = rtrim($config['host'], '/');
|
|
|
|
}
|
|
|
|
|
2024-02-12 16:55:09 +00:00
|
|
|
public function wrap(string $audioURL, Episode $episode): string
|
2022-12-09 15:04:42 +00:00
|
|
|
{
|
2024-02-12 16:55:09 +00:00
|
|
|
// remove scheme from audioURI if https
|
|
|
|
$audioURIWithoutHTTPS = preg_replace('(^https://)', '', $audioURL);
|
2022-12-13 11:56:49 +00:00
|
|
|
|
2024-02-12 16:55:09 +00:00
|
|
|
return $this->host . '/e,pg=' . $episode->podcast->guid . '/' . $audioURIWithoutHTTPS;
|
2022-12-09 15:04:42 +00:00
|
|
|
}
|
|
|
|
}
|