<?php

namespace Licenzo\Services\ShortcodeParser;

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}

use Licenzo\Framework\Support\Arr;

class HandlePipe
{
    public function handle($content, $pipe)
    {
        if (DefaultPipes::hasPipe($pipe)) {
            return DefaultPipes::apply($content, $pipe);
        }

        // hooked via filters
        $handlers = apply_filters('licenzo/shortcode_pipes', []);

        if (Arr::has($handlers, $pipe) && is_callable($handlers[$pipe])) {
            return call_user_func($handlers[$pipe], $content);
        }

        return $content;
    }
}
