<?php
namespace App\Utils\BaseParser\TextCleaner;

abstract class Rule
{
	/**
	 * The regexp used to do the line matching
	 *
	 * @var string
	 */
	public $lineMatch = null;

	/**
	 * The string used to do the search/replace
	 *
	 * @var string
	 */
	public $search = null;

	/**
	 * The string used to do the search/replace
	 *
	 * @var string
	 */
	public $replace = null;

	/**
	 * Build the rule object
	 *
	 * @param string|null $lineMatch
	 * @param string|null $search
	 * @param string|null $replace
	 */
	public function __construct(?string $lineMatch = null, ?string $search = null, ?string $replace = null)
	{
		$this->lineMatch = $lineMatch;
		$this->search = $search;
		$this->replace = $replace;
	}

	abstract function isMatch(string $line);

	abstract function replace(string $line);

}
