<?php

namespace CorkTech\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer;

class TrimStrings extends BaseTrimmer
{
    /**
     * The names of the attributes that should not be trimmed.
     *
     * @var array
     */
    protected $except = [
        'password',
        'password_confirmation',
    ];

    protected function transform($key, $value)
    {
        $array = ['documento', 'cep', 'fone', 'celular'];

        ///if($key === 'cep') dd(preg_replace('/[\D]/', '', $value));
        if (in_array($key, $array)) {
            $value = preg_replace('/[\D]/', '', $value);
        }
        return parent::transform($key, $value); // TODO: Change the autogenerated stub
    }

}
