Download the PHP package gmarsano/chilean-phone-tool without Composer

On this page you can find all versions of the php package gmarsano/chilean-phone-tool. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package chilean-phone-tool

🇨🇱 Chilean Phone Tool ☎️

Introduction

A PHP composer package to work with Chilean 🇨🇱 phone numbers.

Features

Contents

Install

Requirements

Usage

Set a phone number.

parse

Usually you may want to take a phone in any format, check if it's valid and bring it to the desired format. Use parse to set the number, if that the case.

If you parse a valid number you can get the number and prefix just calling these:

Clean an invalid input (use quiet to prevent validation exceptions):

setPhone

Sometimes you just want to know if an input value is a valid phone number without clean or make any changes on it before validation. It's time to use setPhone:

Validation

validate

Use validate to check if it is a valid number. An invalid number will throw an exception with a message giving information about the reasons.

The features of this tool make sense on a valid phone. This is why by default it works with exceptions. But you can use quiet to avoid this behavior, but be careful, if you try to get or format an invalid number you will get the original digits or value depending on the case.

errors and messages

They allow to obtain an array with validation messages if quiet has been used. They may look like aliases, but there is a little difference:

Error messages
code
message
2 Empty digits count.
3 Invalid phone number format.
4 Invalid country code.
5 Invalid prefix.
6 Invalid phone number.

Ignore prefix validation

To avoid prefix validation use ignorePrefix:

fix and luckyFix

Tries to set a valid phone from original input.

Use getOld to get original value.

Sometimes the inputs may lack the Santiago prefix (2). Use luckFix to fix and try to guess if the missing prefix can be fixed.

As you can see, after fix, validation can be true. If you need to check if original was modified because it was invalid, then you can count errors.

Formatting

format

Use format on a valid phone to get the value in standard numbering format.

Choosing format

Give format method the desired format as an argument.

format
example
FormatterInterface::STANDARD_FORMAT +56 9 87-654-321, +56 75 7-654-321
FormatterInterface::PREFIX_FORMAT (9) 87-654-321, (75) 7-654-321
FormatterInterface::DIGITS_FORMAT 56987654321, 56757654321
FormatterInterface::NUMBER_DIGITS_FORMAT 987654321, 757654321

Factory

You can generate a valid phone number using Phone Tool:

Make multiple numbers giving a count as argument to make method.

You can use the unique, cellPhone, landLine or prefix modifiers to make unique numbers, cell phone, landline (red fija), or set a valid prefix manually.

Use format (check choosing format) modifier to give desired format to numbers.

Aliases

methods aliases
get() number
get(true) fullNumber
getPrefix prefix
validate isValid

Inspired by

Freshworks Chilean Bundle

License

MIT License
Copyright (c) 2021 gmarsano


All versions of chilean-phone-tool with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gmarsano/chilean-phone-tool contains the following files

Loading the files please wait ....