Git Product home page Git Product logo

php-ulid's People

Contributors

bepsvpt avatar cfreeh avatar dataground avatar devrck avatar garak avatar hvt avatar ondram avatar peter279k avatar raphaelstolt avatar robinvdvleuten avatar sandrokeil avatar tkrtmy 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  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

php-ulid's Issues

Generated ULID isn't unique

Hello,
I was try the script, but it's seems ulid's last 80 bits isn't unique. Here is example:
$php rr.php
01F46VF3ZZR6FYNWDYQXFA9NQT
01f46vf3zzr6fynwdyqxfa9nqv

and here is the script:

include 'Ulid/Ulid.php';
use Ulid\Ulid;

$ulid = Ulid::generate();
echo (string) $ulid, "\n"; // 01F46VF3ZZR6FYNWDYQXFA9NQT

// Or if you prefer a lowercased output
$ulid = Ulid::generate(true);
echo (string) $ulid, "\n"; // 01f46vf3zzr6fynwdyqxfa9nqv

Only the last char is different, but in specification last 80 bits need to be unique for example in Postgres ulid:

select generate_ulid() from generate_series(1, 10);

   generate_ulid        

01F46WA08EPZTRXY4108T4XAMA
01F46WA08ET4RGV447EKD337ES
01F46WA08EHWXAGBSWQMWHZVHK
01F46WA08EZTD358CC7YGKPRKX
01F46WA08EWRBMMJHCA335794Q
01F46WA08EG7H98DZY789T48VH
01F46WA08EY4X6MQW5986SAP82
01F46WA08EXY9BM9YY284C7GM2
01F46WA08E2W1CTYQ9CX1JW02N
01F46WA08EW8ESAW6QBD65ZK4A
(10 rows)

Regarding Timestamp

Can we generate the timestamp from this ulid? Is there a functionality already present in this package?

decodeTime() return incorrect timestamp

Good day.
Method decodeTime() return incorrect timestamp.
In method generate(): $now = (int) (microtime(true) * 1000);.
Maybe decodeTime() must return $carry/1000 ?

Never updates $lastGenTime

The $lastGenTime static property (which is supposed to be used to keep track of whether it's generating a new ULID in the same millisecond) is never updated, so the code path for handling generating a ULID in the same millisecond will never be executed (and there are no tests for this behaviour).

PHP version limitation

Is there a reason why the minimum version is set to 7.1 in composer.json? I went through the code and couldn't really find any reason for it not to be 7.0 as minimum, unless I missed something.

I'm asking because we're in the midst of finally migrating a more recent version of PHP, which we're doing in steps, but would love to start using this library from 7.0 already. I can definitely help with the changes if needed. Just curious about the why of the limitation. Thanks!

Uppercase by default?

The ulid spec does not state it explicitly, but aren't ulids supposed to be uppercase? Lowercase won't change anything when sorting and it might take less memory and database in some circumstances, but shouldn't the technique be the same over all languages?

Otherwise: Thanks for the library, good job! ๐Ÿ‘

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.