GithubHelp home page GithubHelp logo

shortid-php's People

Contributors

acelaya avatar dependabot-preview[bot] avatar egorgruzdev avatar emanueleminotto avatar garak avatar peter279k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shortid-php's Issues

Shortid isValid()

Bug for the values that has special regex characters: . \ + * ? [ ^ ] $ ( ) { } = ! < > | : -
The line must be:

$ok = preg_match('/(['.$alphabet.']{'.$length.'})/', $value, $matches);

The searched $value must not be converted to preg_quote(), even if contains special regex characters.

Add an option to increase readability

It would be nice to get a new option (maybe a boolean?) to force creation of a more readable string, i.e. avoiding ambiguous characters, like "8B" or "lI" (lowecase L and uppercase I)

Feature: validate passed string

When the object is created via new Shortid($string) there's no validation, currently.
We should add a native exception, and raise it when the passed string is invalid.

PHP 8.1 support

Hey!

I see this project is not being actively built against PHP 8.1

I'm testing the library with PHP 8.1 and it is throwing some deprecation warnings. These two, specifically:

Deprecated: Return type of PUGX\Shortid\Shortid::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /app/vendor/pugx/shortid-php/src/Shortid.php on line 64

Deprecated: PUGX\Shortid\Shortid implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in /app/vendor/pugx/shortid-php/src/Shortid.php on line 5

Would you be open to support PHP 8.1 and add it to the build pipeline? If so, I'm willing to contribute the change.

Why does isValid() accept too long values?

Hi, the current implementation of isValid() accepts too long values as valid ShortIDs. So Shortid::isValid('harmful string stuff', 4) returns true.

The code looks like this is on purpose (checks the string to contain a valid ShortID, not is a valid ShortID), but why? And why is the method not called containsValid then?

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.