vesperabr / fieldtize
Parse, validate and format fields easily.
0.1.0
2022-10-29 22:47 UTC
Requires
- php: ^7.3|^8.0
- giggsey/libphonenumber-for-php: ^8.12
Requires (Dev)
- phpunit/phpunit: ^9.5
- spatie/phpunit-watcher: ^1.23
- symfony/var-dumper: ^5.4
README
Parse, validate and format common fields in an easy way.
Installation
You can install the package via composer:
$ composer require vesperabr/fieldtize
Methods
Every field class has at least this methods:
make()
Returns the field class instance.original()
Returns the original value passed to the class.get()
Returns the formatted value or null if value is invalid.raw()
Returns the value without any masks or null if value is invalid.isValid()
Returns true or false if value is invalid.
Fields
Phone
use Vespera\Fieldtize\Fields\Phone; $phone = Phone::make('1144443333'); $phone->original(); // '1144443333' $phone->get(); // '(11) 4444-3333' $phone->raw(); // '+551144443333' $phone->isValid(); // true echo $phone; // '(11) 4444-3333'
Todo
- Phone field:
getUri()
method - Phone field:
getWhatsappUri()
method - Phone field:
getInternationalNumber()
method - Phone field:
getType()
method - Phone field:
getCountry()
method - CPF field
- CNPJ field
- CPF/CNPJ field
- CEP field
- E-mail field
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.