webhook2xmpp/classes/webhook.php
2021-04-27 09:06:56 +02:00

37 lines
No EOL
720 B
PHP

<?php
namespace classes;
use classes\filter\gitea;
class webhook extends core
{
private $json;
private $filter;
public function __construct(string $json,string $filter)
{
parent::__construct();
if($json)
{
$this->filter = $filter ?? NULL;
$this->json = json_decode($json, false);
}
else
{
throw new \Exception("JSON is required to use this class");
}
}
public function getMessage()
{
if($this->filter === "gitea")
{
$filter = new gitea();
return($filter->formatMessageToReadable($this->json->text));
}
return $this->json->text;
}
}
?>