2017 © Pedro Peláez
 

library laravel-luhn

Luhn algorithm for Laravel

image

marvinlabs/laravel-luhn

Luhn algorithm for Laravel

  • Tuesday, May 8, 2018
  • by vpratfr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 74 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 3600 % Grown

The README.md

Laravel Luhn

Latest Version on Packagist Software License Total Downloads Build Status, (*1)

marvinlabs/laravel-luhn is a laravel package providing various Laravel utilities to work with the Luhn algorithm such as:, (*2)

  • a few validation rules
  • dependency injection
  • facade

The Luhn algorithm is used widely to verify that numbers are valid: credit card numbers, SIREN company codes, etc., (*3)

Installation

You can install the package via composer:, (*4)

``` bash composer require marvinlabs/laravel-luhn, (*5)


If you are using Laravel 5.5, the service provider and facade will automatically be discovered. On earlier versions, you need to do that manually. You must install the service provider: ```php // config/app.php 'providers' => [ ... MarvinLabs\Luhn\LuhnServiceProvider::class ];

And optionally register an alias for the facade., (*6)

// config/app.php
'aliases' => [
    ...
    'Luhn' => MarvinLabs\Luhn\Facades\Luhn::class,
];

Usage

Algorithm implementation

The package provides an implementation to the algorithm interface defined in \MarvinLabs\Luhn\Contracts\LuhnAlgorithm., (*7)

The contract provides 3 public methods to:, (*8)

  • Check if an input string is valid according to the Luhn algorithm
  • Compute the check digit to append to a string in order to make it valid
  • Compute the checksum according to the Luhn algorithm

Facade

A facade is provided to access the Luhn algorithm implementation., (*9)

Luhn::isValid('1234');
Luhn::computeCheckDigit('1234');
Luhn::computeCheckSum('1234');

Dependency injection

You can get an implementation of the Luhn algorithm at any time using the Laravel container., (*10)

$luhn = app(\MarvinLabs\Luhn\Contracts\LuhnAlgorithm::class); // Using the interface
$luhn = app('luhn'); // This shortcut works too, up to you ;)

Validation

The package provides custom rules to validate a string., (*11)

$validator = Validator::make($data, [
    'number1' => 'luhn',         // Using shorthand notation
    'number2' => new LuhnRule(), // Using custom rule class
]);

Version history

See the dedicated change log, (*12)

Credits

License

The MIT License (MIT). Please see License File for more information., (*13)

The Versions

08/05 2018

dev-master

9999999-dev

Luhn algorithm for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel siren siret credit card luhn

08/05 2018

dev-develop

dev-develop

Luhn algorithm for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel siren siret credit card luhn

08/05 2018

v1.0.1

1.0.1.0

Luhn algorithm for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel siren siret credit card luhn

08/05 2018

v1.0.0

1.0.0.0

Luhn algorithm for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel siren siret credit card luhn