PHPackages                             davidmarsmalow/indonesian-phone - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. davidmarsmalow/indonesian-phone

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

davidmarsmalow/indonesian-phone
===============================

Indonesian phone number toolkit for PHP.

v0.2.0(2mo ago)02MITPHPPHP ^8.0

Since May 19Pushed 2mo agoCompare

[ Source](https://github.com/davidmarsmalow/indonesian-phone)[ Packagist](https://packagist.org/packages/davidmarsmalow/indonesian-phone)[ RSS](/packages/davidmarsmalow-indonesian-phone/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

Indonesian Phone
================

[](#indonesian-phone)

[![Latest Version on Packagist](https://camo.githubusercontent.com/91ef41209982fd47f1f1ef1bdebf872fc5c2376371e0ab49670a50a02d1bb92f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64617669646d6172736d616c6f772f696e646f6e657369616e2d70686f6e652e737667)](https://packagist.org/packages/davidmarsmalow/indonesian-phone)[![Total Downloads](https://camo.githubusercontent.com/1864c262829b04b8815eeba927066c30b67050abe56873ca3e6b3b2db9cb656d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64617669646d6172736d616c6f772f696e646f6e657369616e2d70686f6e652e737667)](https://packagist.org/packages/davidmarsmalow/indonesian-phone)[![License](https://camo.githubusercontent.com/1bedf5ddf4c371c409059fa801991b03e965d545ebbf3c4f7b13e7d001d32a9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64617669646d6172736d616c6f772f696e646f6e657369616e2d70686f6e652e737667)](https://packagist.org/packages/davidmarsmalow/indonesian-phone)

Indonesian phone number toolkit for PHP.

Installation
------------

[](#installation)

```
composer require davidmarsmalow/indonesian-phone
```

Usage
-----

[](#usage)

```
use Davidmarsmalow\IndonesianPhone\Phone;

$phone = Phone::make('0812-3456-7890');

$phone->raw(); // 0812-3456-7890
$phone->normalize(); // 6281234567890
$phone->isValid();  // true
$phone->isMobile(); // true
$phone->isFixedLine(); // false
$phone->type(); // mobile
$phone->toE164(); // +6281234567890
```

Raw Value
---------

[](#raw-value)

`raw()` returns the original value passed to `Phone::make()`.

```
Phone::make('0812-3456-7890')->raw(); // 0812-3456-7890
```

Normalization
-------------

[](#normalization)

`normalize()` removes non-numeric characters and converts local Indonesian numbers that start with `0` into country-code format.

```
Phone::make('0812-3456-7890')->normalize(); // 6281234567890
Phone::make('+62 812 3456 7890')->normalize(); // 6281234567890
Phone::make('(021) 1234 5678')->normalize(); // 622112345678
```

Validation
----------

[](#validation)

`isValid()` returns `true` when the number is recognized as either a mobile or fixed-line Indonesian phone number.

```
Phone::make('0812-3456-7890')->isValid(); // true
Phone::make('(021) 1234 5678')->isValid(); // true
Phone::make('12345')->isValid(); // false
```

Use `isMobile()` when you only want to accept Indonesian mobile numbers.

```
Phone::make('0812-3456-7890')->isMobile(); // true
Phone::make('(021) 1234 5678')->isMobile(); // false
```

Use `isFixedLine()` when you only want to accept Indonesian fixed-line numbers.

```
Phone::make('(021) 1234 5678')->isFixedLine(); // true
Phone::make('0812-3456-7890')->isFixedLine(); // false
```

Type Detection
--------------

[](#type-detection)

`type()` returns the detected phone number type, or `null` when the number is invalid or unrecognized.

```
Phone::make('0812-3456-7890')->type(); // mobile
Phone::make('(021) 1234 5678')->type(); // fixed_line
Phone::make('12345')->type(); // null
```

You can compare the result using the provided constants.

```
Phone::TYPE_MOBILE; // mobile
Phone::TYPE_FIXED_LINE; // fixed_line
```

E.164 Format
------------

[](#e164-format)

`toE164()` returns the phone number in E.164 format when valid, or `null` when invalid.

```
Phone::make('0812-3456-7890')->toE164(); // +6281234567890
Phone::make('(021) 1234 5678')->toE164(); // +622112345678
Phone::make('12345')->toE164(); // null
```

WhatsApp Link
-------------

[](#whatsapp-link)

Generate WhatsApp links directly from Indonesian phone numbers.

```
use Davidmarsmalow\IndonesianPhone\Phone;

Phone::make('0812-3456-7890')->toWhatsappLink();

// https://wa.me/6281234567890
```

### With Prefilled Message

[](#with-prefilled-message)

```
Phone::make('0812-3456-7890')
    ->toWhatsappLink('Hello World');

// https://wa.me/6281234567890?text=Hello+World
```

### Invalid Number

[](#invalid-number)

Returns `null` when the phone number is invalid.

```
Phone::make('abc')->toWhatsappLink();

// null
```

Masking
-------

[](#masking)

`mask()` returns a masked normalized phone number when valid, or `null` when invalid`.

```
Phone::make('0812-3456-7890')->mask(); // 6281*****7890
Phone::make('(021) 1234 5678')->mask(); // 6221****5678
Phone::make('12345')->mask(); // null
```

You can customize the visible digits and mask character.

```
Phone::make('0812-3456-7890')->mask(5, 4, '#'); // 62812####7890
Phone::make('0812-3456-7890')->mask(4, 4, '•'); // 6281•••••7890
Phone::make('0812-3456-7890')->mask(4, 4, '🔒'); // 6281🔒🔒🔒🔒🔒7890
```

You can also use emoji as the mask character because why not.

The mask character must be exactly one character. Unicode and emoji mask characters are supported through PHP's `mbstring` extension.

Testing
-------

[](#testing)

```
composer test
```

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance87

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

66d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5811f1e13b4ef0b6b8d27b791dac44b4c5337afe364600352acf943e597632dc?d=identicon)[davidmarsmalow](/maintainers/davidmarsmalow)

---

Top Contributors

[![davidmarsmalow](https://avatars.githubusercontent.com/u/52326580?v=4)](https://github.com/davidmarsmalow "davidmarsmalow (15 commits)")

---

Tags

validationphoneindonesiaphone-numberindonesianE164

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/davidmarsmalow-indonesian-phone/health.svg)

```
[![Health](https://phpackages.com/badges/davidmarsmalow-indonesian-phone/health.svg)](https://phpackages.com/packages/davidmarsmalow-indonesian-phone)
```

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k39.7M151](/packages/propaganistas-laravel-phone)[composer/semver

Version comparison library that offers utilities, version constraint parsing and validation.

3.3k522.3M1.0k](/packages/composer-semver)[giggsey/libphonenumber-for-php

A library for parsing, formatting, storing and validating international phone numbers, a PHP Port of Google's libphonenumber.

5.0k159.6M539](/packages/giggsey-libphonenumber-for-php)[respect/validation

The most awesome validation engine ever created for PHP

6.0k39.9M418](/packages/respect-validation)[opis/json-schema

Json Schema Validator for PHP

65543.6M320](/packages/opis-json-schema)[giggsey/libphonenumber-for-php-lite

A lite version of giggsey/libphonenumber-for-php, which is a PHP Port of Google's libphonenumber

9416.6M76](/packages/giggsey-libphonenumber-for-php-lite)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
