You are here

interface BrazilianIdsServiceInterface in Brazilian IDs 8

Defines the interface of the Brazilian IDs service.

Hierarchy

Expanded class hierarchy of BrazilianIdsServiceInterface

All classes that implement BrazilianIdsServiceInterface

3 files declare their use of BrazilianIdsServiceInterface
CnpjFormatter.php in src/Plugin/Field/FieldFormatter/CnpjFormatter.php
CpfCnpjFormatter.php in src/Plugin/Field/FieldFormatter/CpfCnpjFormatter.php
CpfFormatter.php in src/Plugin/Field/FieldFormatter/CpfFormatter.php

File

src/BrazilianIdsServiceInterface.php, line 8

Namespace

Drupal\brazilian_ids
View source
interface BrazilianIdsServiceInterface {

  /**
   * Cleans up Brazilian IDs numbers.
   */
  public function clean($value);

  /**
   * Validates CPF numbers.
   *
   * @param string $value
   *   The value of the CPF number to be validated.
   *
   * @param array $error
   *   If provided, it is filled with the error message at $error['message'] if any.
   *
   * @return bool
   *   Returns TRUE if the CPF number is valid. Otherwise, returns FALSE.
   */
  public function validateCpf($value, array &$error = []);

  /**
   * Validates CNPJ numbers.
   *
   * @param string $value
   *   The value of the CNPJ number to be validated.
   *
   * @param array $error
   *   If provided, it is filled with the error message at $error['message'] if any.
   *
   * @return bool
   *   Returns TRUE if the CNPJ number is valid. Otherwise, returns FALSE.
   */
  public function validateCnpj($value, array &$error = []);

  /**
   * Validates CPF or CNPJ numbers depending on the number of digits.
   *
   * @param string $value
   *   The value of the CPF or CNPJ number to be validated.
   *
   * @param array $error
   *   If provided, it is filled with the error message at $error['message'] if any.
   *
   * @return bool
   *   Returns TRUE if the CPF or CNPJ number is valid. Otherwise, returns FALSE.
   */
  public function validateCpfCnpj($value, array &$error = []);

  /**
   * Formats a CPF number like 999.999.999-99.
   *
   * @param string $value
   *   The CPF number to be formatted.
   *
   * @return string
   *   The formatted CPF number.
   */
  public function formatCpf($value);

  /**
   * Formats a CNPJ number like 99.999.999/9999-99.
   *
   * @param string $value
   *   The CNPJ number to be formatted.
   *
   * @return string
   *   The formatted CNPJ number.
   */
  public function formatCnpj($value);

  /**
   * Formats a CPF number like 999.999.999-99 or a CNPJ number like
   * 99.999.999/9999-99 depending on the number of digits.
   *
   * @param string $value
   *   The CPF or CNPJ number to be formatted.
   *
   * @return string
   *   The formatted CPF or CNPJ number.
   */
  public function formatCpfCnpj($value);

}

Members

Namesort descending Modifiers Type Description Overrides
BrazilianIdsServiceInterface::clean public function Cleans up Brazilian IDs numbers. 1
BrazilianIdsServiceInterface::formatCnpj public function Formats a CNPJ number like 99.999.999/9999-99. 1
BrazilianIdsServiceInterface::formatCpf public function Formats a CPF number like 999.999.999-99. 1
BrazilianIdsServiceInterface::formatCpfCnpj public function Formats a CPF number like 999.999.999-99 or a CNPJ number like 99.999.999/9999-99 depending on the number of digits. 1
BrazilianIdsServiceInterface::validateCnpj public function Validates CNPJ numbers. 1
BrazilianIdsServiceInterface::validateCpf public function Validates CPF numbers. 1
BrazilianIdsServiceInterface::validateCpfCnpj public function Validates CPF or CNPJ numbers depending on the number of digits. 1