<?php

namespace Edge\Filter;

use Zend\Filter\FilterInterface;

class StrReplace implements FilterInterface
{
    protected $search;

    protected $replace;

    public function __construct($search, $replace)
    {
        $this->search  = $search;
        $this->replace = $replace;
    }

    public function filter($value)
    {
        if (is_string($value)) {
            $value = str_replace($this->search, $this->replace, $value);
        }
        
        return $value;
    }
}

<?php

namespace Edge\Filter;

use Zend\Filter\FilterInterface;

class StrReplace implements FilterInterface
{
    protected $search;

    protected $replace;

    public function __construct($search, $replace)
    {
        $this->search  = $search;
        $this->replace = $replace;
    }

    public function filter($value)
    {
        if (null !== $value) {
            $value = str_replace($this->search, $this->replace, $value);
        }
        return $value;
    }
}
--- 
+++ 
@@ -18,9 +18,10 @@
 
     public function filter($value)
     {
-        if (null !== $value) {
+        if (is_string($value)) {
             $value = str_replace($this->search, $this->replace, $value);
         }
+        
         return $value;
     }
 }
Check if value is a string first