diff --git a/src/Documento.php b/src/Documento.php index 3c0ad5a..5cd54e1 100644 --- a/src/Documento.php +++ b/src/Documento.php @@ -2,7 +2,7 @@ namespace Bissolli\ValidadorCpfCnpj; -class Documento +class Documento extends DocumentoAbstract { /** * Value to be validated @@ -11,21 +11,6 @@ class Documento */ public $obj; - /** - * Create a new Documento instance - * - * @param string $value - */ - public function __construct($value = null) - { - $value = (string) preg_replace('/[^0-9]/', '', $value); - - if (strlen($value) === 11) - $this->obj = new CPF($value); - else - $this->obj = new CNPJ($value); - } - /** * Get document type * @@ -68,4 +53,21 @@ public function getValue() { return $this->obj->getValue(); } + + /** + * Set the clean value + * + * @return self + */ + public function setValue($value) + { + $value = (string) preg_replace('/[^0-9]/', '', $value); + + if (strlen($value) === 11) + $this->obj = new CPF($value); + else + $this->obj = new CNPJ($value); + + return $this; + } }