2017 © Pedro Peláez
 

library masknizzer

Masknizzer is a package for the application of masks in fields.

image

gabrielanhaia/masknizzer

Masknizzer is a package for the application of masks in fields.

  • Sunday, July 3, 2016
  • by gabrielanhaia
  • Repository
  • 1 Watchers
  • 2 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Masknizzer

Masking fields has never been so easy!, (*1)

Installation (Instalação)

Installation by composer (Instalação pelo composer):, (*2)

composer require gabrielanhaia/masknizzer

or add the dependency on your composer.json and: (ou adicione a denpendência em seu composer.json e:), (*3)

composer install

Use (Uso)

1 - Creating a new mask (Criando uma nova máscara):

You can use '\Masknizzer\EnumMasks' already has several formats or (É possível usar os formatos de máscara padrão em '\Masknizzer\EnumMasks' ou), (*4)

use Eloquent\Enumeration\AbstractEnumeration;

class CustomEnumMasks extends AbstractEnumeration
{
    /** @var string POSTAL_CODE Mask Brazilian postcode. / Máscara para código postal(CEP) Brasileiro. */
    const POSTAL_CODE = '#####-###';

    /** @var string PHONE_NUMBER Mask for 10-digit phone with area code. /
     *                           Máscara para telefone de 10 dígitos junto com código de região.
     */
    const PHONE_NUMBER_10 = '(##) ####-####';

    /** @var string PHONE_NUMBER Mask for 11-digit phone with area code. /
     *                           Máscara para telefone de 10 dígitos junto com código de região.
     */
    const PHONE_NUMBER_11 = '(##) ####-#####';
}

Note: The masks should extender 'Eloquent\Enumeration\AbstractEnumeration' and follow the pattern of the mask defined in '\Masknizzer\EnumMasks'., (*5)

Observação: As máscaras customizadas devem extender de 'Eloquent\Enumeration\AbstractEnumeration' e as constantes devem seguir o padrão de '\Masknizzer\EnumMasks'., (*6)

2 - Building a type of object masks (Construindo um objeto do tipo das máscaras):

use Masknizzer\EnumMasks;
use Masknizzer\MaskFactory;

$maskFieldPostalCode = MaskFactory::factory(EnumMasks::POSTAL_CODE(), 12345678);

or pass an Enum array as the first parameter , the function itself will decide which mask to use according to the number of characters of the field passed in the second parameter., (*7)

ou passe uma lista de Enum no primeiro parâmetro da factory, a própria classe irá decidir de acordo com o número de caracteres do campo qual máscara irá usar., (*8)

$maskGroupPhoneNumber = [
    EnumMasks::PHONE_NUMBER_10(),
    EnumMasks::PHONE_NUMBER_11()
];

$maskFieldPhoneNumbers = MaskFactory::factory($maskGroupPhoneNumber, 51123456789);

3 - Processing the mask in field (Processando a máscara no campo):

$maskedField = $maskFieldPostalCode->mask();

In the example the result is (No exemplo o resultado será): 12345-678, (*9)

The Versions

03/07 2016

dev-master

9999999-dev

Masknizzer is a package for the application of masks in fields.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Anhaia

mask masknizzer