Commit Graph

23 Commits

Author SHA1 Message Date
Ben Ramsey aa1e488afa feat: support version 7 (Unix Epoch time) UUIDs 2022-09-13 22:13:33 -05:00
Bilge 7947413a76 Use assertSame instead of assertEquals. 2020-08-23 13:53:19 +01:00
Marco Pivetta b805572537 Ensure that Uuid::uuidX() generators produce instances equivalent to Uuid::fromString() and Uuid::fromBytes()
With this change, `Uuid::uuid1()`, `Uuid::uuid2()` and so forth now produce a `LazyUuidFromString` instance, which
is both more memory efficient and comparable to `Uuid::fromString()` instances in other tools, such as within
PHPUnit's `Assertion::assertEqual()`, which would reject any two objects not matching each other's types.

Before this patch, `Assertion::assertEquals(Uuid::uuid5(...), Uuid::fromString(...))` would always fail due to
different subtypes produced by the two factory methods.
2020-07-09 13:57:30 +02:00
Ben Ramsey fb4f54fb84 Address static analysis issues 2020-02-08 13:14:17 -06:00
Ben Ramsey 0bff9e8660 Add NameGeneratorInterface and generators for v3 and v5 UUIDs 2020-02-08 13:12:20 -06:00
Marco Pivetta a252f29847 Import used functions and constants via use statement to disallow ambiguity for compiler/static-analysis
As documented in https://wiki.php.net/rfc/use_global_elements, the engine (by default) does a local namespace
lookup, then falls back to global namespace when first calling a global function referenced in namespaced code,
unless that function is referenced via fully qualified name (FQN).

By using the FQN, the actual symbol can be looked up at compile-time, both by the PHP engine and by static analysis
tooling, allowing for compiler (in particular) optimizations to replace known hot-path functions with specialized opcodes.

Sadly, no actual benchmark at hand: the improvements can be minimal or massive, depending on where this library is
used (tight loops being most relevant).
2020-02-03 13:15:35 -06:00
Ben Ramsey 5fa4eb4f17 Add fromDateTime() to create version 1 UUIDs from DateTime instances
Fixes #28
2020-02-03 00:48:41 -06:00
Ben Ramsey 72a2312f62 Support generation of version 2 (DCE Security) UUIDs 2020-01-18 12:14:01 -06:00
Ben Ramsey d6ed9b3832 Introduce separate class support for GUIDs 2020-01-18 12:13:57 -06:00
Ben Ramsey d4dd45e908 Apply fields functionality to Uuid class 2020-01-18 12:13:57 -06:00
Ben Ramsey 0d7b8c2b7a Update coding style to include PSR-12, among other options
This also includes heavy use of slevomat/coding-standard to apply
various checks to the code, based on maintainer (me) preference.
2020-01-18 12:13:55 -06:00
Ben Ramsey 81f0f9a9b4 Clean-up tests and use PHPStan max level for tests 2020-01-18 12:13:09 -06:00
Martin Hujer 049d5acf7a Use ::class constants where possible
It helps with refactorings and static analysis, because you can easily
tell if the class is missing or not.
2020-01-18 12:13:07 -06:00
Ben Peachey dbb9a8b6d1 Changes all usage in Tests of getMock with getMockBuilder. 2017-10-17 12:46:25 +02:00
Jessica Mauerhan 02fc392d84 formatting 2016-10-18 08:53:11 -05:00
Jessica Mauerhan bf1513433f fixing formatting 2016-10-17 20:56:57 -05:00
Jessica Mauerhan d4ece57761 Adding test coverage for getters/setters currently untested. 2016-10-17 20:53:01 -05:00
Jessica Mauerhan 0a620d1966 Added another failing test case for GH Issue $131 2016-09-30 16:00:46 -04:00
Andreas Möller 7ff6fff06d Fix: Move tests one up 2016-09-15 08:31:27 +02:00
Ben Ramsey f5e96b6af7 Restructure tests 2015-10-03 10:59:44 -05:00
Ben Ramsey d67c3490a8 Change namespace to "Ramsey"; closes #48 2015-04-25 12:11:37 -05:00
Thibaud Fabre 84123b2060 Remove all env related logic from factory
Defers all environment related decisions to factory initialization
All behavior is customizable through DI, but all deps are initialized to proper default instances
Removes static factory configuration
2014-11-08 12:41:40 +01:00
Thibaud Fabre fead6f3223 Refactor in the spirit of #1 & #34 2014-10-30 15:16:59 +01:00