Skip to content

Commit

Permalink
Updated Documento.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Luz authored Apr 22, 2018
1 parent 34cf4bb commit 7d37692
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/Documento.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Bissolli\ValidadorCpfCnpj;

class Documento
class Documento extends DocumentoAbstract
{
/**
* Value to be validated
Expand All @@ -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
*
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 7d37692

Please sign in to comment.