PUGX / shortid-php

An implementation of ShortId in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[RFC][BC] builder with and a new behavior

liuggio opened this issue · comments

Hi all,
the idea is to have only 2 classes

The Generator with a behavior like:

$shortId = new Generator()
  ->setLenght(7)
  ->setFactory(/* the ircmaxell/RandomLib factory adapter */)
  ->setSeed(1)
  ->setEasyToRead(false)
  ->getString("ABCDEFG123456") // or getInt?
;

and the ShortId class would be a Value Object with a __toString() and is possible to create itself directly from the factory method

$shortId = ShortId::generate(/*alphabet*/); //it uses the Generator with the default options

Feel free to write a PR.
More details are welcome (maybe on slack?)