<?php

namespace FiloBlu\Flow\Model\Filters;

/**
 * Class StrReplace
 * @package FiloBlu\Flow\Model\Filters
 */
class StrReplace extends AbstractFilter
{

    /**
     * @param $value
     * @param $args
     * @return mixed|string
     */
    public function filter($value, $args)
    {
        $v = trim($value ?? '');

        if ($args && isset($args['find'], $args['replace']) && count($args)) {
            return str_replace($args['find'], $args['replace'], $v);
        }

        return $v;
    }
}
