for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of laravel.su package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace App\Services\ContentRenderer;
* Class Renderer.
abstract class AbstractRenderer implements ContentRenderInterface
{
private const EVENT_PARSE_BEFORE = 'parse.before';
private const EVENT_PARSE_AFTER = 'parse.after';
* @var array|\Closure[]
private $before = [];
private $after = [];
* @param \Closure $callback
* @return $this|ContentRenderInterface
public function before(\Closure $callback): ContentRenderInterface
$this->before[] = $callback;
return $this;
}
public function after(\Closure $callback): ContentRenderInterface
$this->after[] = $callback;
* @param string $body
* @return string
protected function fireBefore(string $body): string
foreach ($this->before as $before) {
if (is_string($parsed = $before($body))) {
$body = $parsed;
return $body;
protected function fireAfter(string $body): string
foreach ($this->after as $after) {
if (is_string($parsed = $after($body))) {