Download the PHP package pittacusw/chilean-bundle without Composer
On this page you can find all versions of the php package pittacusw/chilean-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package chilean-bundle
Chilean Bundle
A PHP composer package with Chilean validations, common variables, etc. Viva Chile Mier...
This package includes:
- R.U.T. validation
- More functions coming soon...
Installation
Step 1: Composer
From the command line, run:
If you're not using Laravel, you are done.
Step 2: Laravel Service Provider
If you're using Laravel 5.5 this package supports Auto-Discovery. So you can skip this step.
For Laravel 5.4 or below
Append this line to your providers
array in your config/app.php
file:
and you can add the RUT
Facade
Usage
The Basics
You can use the RUT object, but I recommend using the Rut::parse() method.
The parse()
method
Is the recommended way of using the object. It will automatically separate the Verification Number (Dígito verrificador) and the rest of the number.
The set()
method
This is a shortcut for (new Rut($number, $vn))
The validate()
& isValid()
method
validate()
is an alias of isValid()
Invalid Formatted R.U.T.
if the R.U.T. is invalid, it will return false
Invalid Formatted R.U.T.
if the R.U.T. has a wrong format, it will throw an Freshwork\ChileanBundle\Exceptions\InvalidFormatException
Quiet
mode
You can prevent that the object throws an InvalidFormatException
, so validate()
will just return false, using the quiet()
mehtod.
You can re-enable exceptions with use_exceptions()
The calculateVerificationNumber()
method
You can get the correct verification number of a RUT. Note that the we are passing just one argument to the set()
method. We are not defining a verification number.
Esta clase se basa en está simple, pero eficiente función: http://www.dcc.uchile.cl/~mortega/microcodigos/validarrut/php.php
The format()
method
Return the Rut object as string with a definied format.
The normalize()
method
If you are saving RUTs in the database, I recommend saving the normalized rut string. This method is an alias of ->format(Rut::FORMAT_ESCAPED)
The toArray()
method
Return the Rut object as string with a definied format.
The fix()
method
Fix the current RUT. It will take the number part of the RUT (without verification number) and it will calculate what's the correct verification number for that RUT and then updates the verification number with this result.
The vn()
and number()
method
You can set and get the RUT number and verification number with this methods. If no argumen are passed to this methods, it will return the corresponding value. Otherwise, it sets the value.
Laravel
Validations
If you're using the service Provider, you can validate ruts usign the validation system of Laravel using the cl_rut
validation.
Examples
RUT Generator
This generates ten random RUT's between 1.000.000 and 25.000.000
Even a shorter syntaxis:
Licencia y Postalware
Puedes usar este paquete gratuitamente sin ninguna restricción, aunque como está de moda, implementamos una licencia 'Postalware'. Si usas este paquete en producción y te gusta como funciona, Agradeceríamos bastante si nos envías una postal de tu ciudad/comuna, una nota de agradecimiento o un súper8.
Dirección Nombre: Gonzalo De Spirito Apoquindo 5980. Piso 17, Las Condes, Santiago. Chile,
Testing
You can run the tests as ./vendor/bin/codecept run
Contributing
Please, feel free to contact me at [email protected]