Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Algerian Mobile Phone Number Laravel Package

cherif/algerian-mobile-phone-number

View on GitHub
Deep Wiki
Context7

Algerian mobile phone number value object

Algerian mobile phone number value object implementation that can be used in your domain models or to integrate with your favorite framework.

Installation

composer require cherif/algerian-mobile-phone-number

Usage:

Instantiation:

The class doesn't have a public constructor, it has a named constructor instead in order to preseve its invariants:

use Cherif\AlgerianMobilePhoneNumber\AlgerianMobilePhoneNumber;

$phoneNumber = AlgerianMobilePhoneNumber::fromString('0699000000');

Or:

use Cherif\AlgerianMobilePhoneNumber\AlgerianMobilePhoneNumber;

$phoneNumber = AlgerianMobilePhoneNumber::fromString('06 99 00 00 00');

Or:

use Cherif\AlgerianMobilePhoneNumber\AlgerianMobilePhoneNumber;

$phoneNumber = AlgerianMobilePhoneNumber::fromString('06-99-00-00-00'); //

The value object class accepts international phone indicative, 00213 or +213, too.

NOTE: For now only space and dash "-" separated numbers are accepted.

API:

asString

To get the string value of the object:

$phoneNumber->asString(); // -> '0699000000'

equals

For comparaison check:

$other = AlgerianMobilePhoneNumber::fromString('0699000000');
$phoneNumber->equals($other); // -> true

isMobilis, isDjezzy and isOoredoo

To know if the object respresents a Mobilis, Djezzy or Ooredoo phone number

$phoneNumber = AlgerianMobilePhoneNumber::fromString('0699000000');
$phoneNumber->isMobilis(); // -> true
$phoneNumber->isDjezzy(); // -> false
$phoneNumber->isOoredoo(); // -> false

withNumber

use Cherif\AlgerianMobilePhoneNumber\AlgerianMobilePhoneNumber;

$phoneNumber = AlgerianMobilePhoneNumber::fromString('06-99-00-00-00');
$phoneNumber->withNumber('07-99-00-00-00'); // Will return a new instance that represents the new number

__toString

Casts the value object to string:

$phoneNumber = AlgerianMobilePhoneNumber::fromString('0699000000');
(string)$phoneNumber; // -> '0699000000'

Contribution

Contributions are welcome to make this library better.

  • Clone the repo:
$ git clone git@github.com:cherifGsoul/php-algerian-mobile-phone-number.git

and enter to the cloned repository directory.

  • Install dependencies:
$ composer install

Testing:

Run composer script for testing:

$ composer test

License

MIT License.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle