vaened/php-sequence-generator

Facilitates the generation and autocompletion of a sequential value in the database

Installs: 104 153

Dependents: 2

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/vaened/php-sequence-generator

v2.0 2024-09-14 21:42 UTC

This package is auto-updated.

Last update: 2025-10-15 00:09:02 UTC


README

Facilitates the generation and autocompletion of a sequential value in the database

// Initialize Repository
$defaultRepository = new MysqlRepository(table: 'sequences');
$anotherRepository = new MysqlRepository(table: 'secuencias');

$normalizer = new Normalizer($defaultRepository);
$generator  = new Generator();
$resolver   = new SequentialIncrementer($normalizer, $generator);

// Define Series
$series = [
    Serie::for('number')->alias('invoice'),

    new Collection($anotherRepository, [
        Serie::for('serie_number')->styles([
            new FixedLength(8),
            new Prefixed('B')
        ]),
    ]),
];

// Make increments
$resolver->resolve('payments', $series);