Skip to content

Commit

Permalink
chore: PHP formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Jonas Ullrich committed Apr 28, 2019
1 parent 5d67682 commit c368074
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions classes/Webhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,20 @@ private static function formatHookConfig(string $hookName): array
$hooks = kirby()->option('pju.webhooks.hooks');
$config = $hooks[$hookName];

if (is_string($config))
{
if (is_string($config)) {
$config = ['url' => $config];
}

if (!isset($config['method']))
{
if (!isset($config['method'])) {
$config['method'] = 'POST';
}

if (isset($config['payload']) && is_callable($config['payload']))
{
if (isset($config['payload']) && is_callable($config['payload'])) {
$payload = $config['payload'];
$config['payload'] = $payload();
}

$config['useOutdated'] = $config['useOutdated'] ?? true;
$config['showOutdated'] = $config['showOutdated'] ?? true;

return array_merge(['name' => $hookName], $config);
}
Expand Down Expand Up @@ -91,8 +88,7 @@ public static function getHook(string $hookName): array
*/
public static function setState(string $hookName, string $status)
{
if (!in_array($status, Webhooks::$allowed))
{
if (!in_array($status, Webhooks::$allowed)) {
throw new InvalidArgumentException('Status not allowed');
}

Expand All @@ -105,8 +101,7 @@ public static function setState(string $hookName, string $status)
$state['status'] = $status;

// Don't save the time if we update to success - we want to know when the hook was triggered
if ($status !== 'success')
{
if ($status !== 'success') {
$state['updated'] = time();
}

Expand All @@ -126,8 +121,7 @@ public static function runCallback(string $hookName, string $status)
{
$hook = Webhooks::getHook($hookName);

if (isset($hook['callback']) && is_callable($hook['callback']))
{
if (isset($hook['callback']) && is_callable($hook['callback'])) {
$req = kirby()->request();
$hook['callback']($status, $req);
}
Expand Down

0 comments on commit c368074

Please sign in to comment.