Nikita Konstantinov
580027e79b
Remove redundant bitwise operations
2019-11-30 13:39:14 -08:00
Ben Ramsey
64ba9a2767
Clean up code according to PhpStorm inspections report
2019-11-30 13:14:52 -08:00
Ben Ramsey
feb3eb50d1
Revert "Mark toString() method as deprecated, scheduled for removal in 4.0.0"
...
This reverts commit 4c467ce4d5 .
For more information, please see the discussion at:
https://github.com/ramsey/uuid/commit/4c467ce4d5a72c3cf0832c813d4d84d222c3d4bb#commitcomment-31174263
Also refer to the discussion at:
https://github.com/ShittySoft/symfony-live-berlin-2018-doctrine-tutorial/pull/3#issuecomment-460441229
TL;DR: I am retaining `toString()` for improved static analysis and
long-term stability.
2019-11-30 12:33:16 -08:00
Ben Ramsey
555e5c1102
Test usage of PHP_OS constant
2019-11-30 12:18:43 -08:00
Ben Ramsey
92d12eb5c6
Merge branch '3.x' of https://github.com/bkayranci/uuid into bkayranci-3.x
2019-11-30 11:51:54 -08:00
Alessandro Minoccheri
c4cc058f3d
change array declarations
2019-11-30 09:10:09 -08:00
Ben Ramsey
466629a399
Use a high-strength generator by default, when using RandomLibAdapter
2019-11-30 09:10:09 -08:00
karsasmus
2824db17c8
Change library ircmaxell/random-lib to paragonie/random-lib
2019-11-30 09:10:09 -08:00
Türkalp Burak KAYRANCIOĞLU
c0183c581e
PHP_OS predefined constant was used instead of php_uname() function.
2019-10-26 13:34:38 +03:00
Ben Ramsey
4c467ce4d5
Mark toString() method as deprecated, scheduled for removal in 4.0.0
2018-08-12 10:49:01 -05:00
Ben Ramsey
59c8bb0840
Update the deprecation messages
2018-08-12 09:43:21 -05:00
Ben Ramsey
cd92bfa43c
Mark SodiumRandomGenerator as deprecated
2018-08-11 21:30:34 -05:00
Ben Ramsey
7397e2f431
Mark MtRandGenerator and OpenSslGenerator as deprecated
2018-08-11 21:23:49 -05:00
Ben Ramsey
5d5eab97ee
Add ext-json as a dependency
2018-08-05 16:59:04 -05:00
Ben Ramsey
8d621488c4
Check whether passthru() is disabled
...
If passthru() is disabled in php.ini, this will force the
SystemNodeProvider to return `false` for the node. Using the default
FallbackNodeProvider, ramsey/uuid will default to the
RandomNodeProvider, in these cases.
Closes #114
2018-07-19 16:53:00 -05:00
Ben Ramsey
6616ec086c
Merge pull request #232 from marcosh/master
...
add annotations for thrown exceptions
2018-07-19 15:24:41 -05:00
Ben Ramsey
b8cac9278c
Merge branch 'SystemNodeProvider-FreeBSD-support' of https://github.com/kalifg/uuid into kalifg-SystemNodeProvider-FreeBSD-support
2018-07-19 15:08:45 -05:00
Marco Perone
4b7374129c
add annotations for thrown exceptions
2018-07-09 09:04:12 +02:00
Lee Boynton
2804748423
Don't allow UUIDs to have trailing newline
2018-05-02 18:54:33 +01:00
Ben Peachey
62628862df
Improvements to the SystemNodeProviderTest class ( #211 )
...
* Changes location of providers in the SystemNodeProviderTest
They are now grouped at the bottom of the class.
* Adds logic to SystemNodeProviderTest.
* Changes call to `file_get_contents` SystemNodeProvider so it can be
mocked.
* Changes SystemNodeProviderTest so native PHP functions are mocked
instead of the class under test.
* Changes SystemNodeProviderTest so "\n" is used instead of PHP_EOL
As the (input or output) of the tests is not system dependant it does
not make sense to use PHP_EOL. All of these instance have been
replaced for the sake of readability and stating intent more clearly.
* Adds dataprovider to SystemNodeProvider main test for input
variations.
* Adds OS to SystemNodeProviderTest dataprovider for Linux fail
scenario.
* Adds test for SystemNodeProvider to ensure invalid values are not
accepted.
* Changes names of dataproviders in SystemNodeProviderTest for
consistency.
* Changes SystemNodeProviderTest by grouping dataproviders together.
* Changes method in SystemNodeProviderTest to use the provided mock
functions.
* Fixes PSR-2 coding conventions in SystemNodeProviderTest.
* Minor change to SystemNodeProviderTest based on review.
2018-02-07 17:28:02 -06:00
kalifg
a7492800e2
Add support for determining MAC address on FreeBSD systems
2018-02-07 15:15:49 -06:00
Marcel Hernandez
76efebe0ac
generate random clockSeq with random_int() instead of mt_rand()
2018-01-19 16:17:49 -06:00
Marcel Hernandez
3567caf3f9
fixed off-by-one error on DefaultTimeGenerator
2018-01-19 16:17:36 -06:00
Ben Ramsey
89c3c1777e
Fix capitalization of the getSysfs() method
2018-01-16 14:14:34 -06:00
Ben Ramsey
901c3e540d
Handle cases where glob() returns false
...
Fixes #203
2018-01-16 14:11:58 -06:00
Robbert Müller
10e022c05c
bug fixes
...
- add missing default value
- invert logic, because it was doing it the wrong way around
2017-10-18 10:32:45 +02:00
Ben Ramsey
bb9c49a32f
Merge branch 'master' into add-sysfs-option
2017-10-09 09:19:48 -05:00
Robbert Müller
cfafc97fc0
Add sysfs option for linux system
...
Linux offers a sysfs interface to the macaddresses of the system network
interfaces without calling exec.
This enables stable system based UUID generation even on docker images
like php:7
2017-10-06 19:57:30 +02:00
Ben Ramsey
dced71b87a
Use str_pad() and dechex() instead of sprint()
...
This is a micro-optimization that improves memory usage when generating
large quantities of UUIDs. See #159 and #160 .
2017-09-22 14:27:30 -05:00
Ben Ramsey
5c38d41ccb
Use sprintf() to prefix zeros on the returned node hex string
2017-09-22 13:03:41 -05:00
Ben Ramsey
1ec0826a40
Set the multicast bit for random nodes, according to RFC 4122, §4.5
...
Borrows the idea from cf1c981414 to
properly set the multicast bit to the "least significant bit of the
first octet of the node ID."
When merged, this will close #171 and #170
2017-09-22 12:54:15 -05:00
Ben Ramsey
aab08bb08a
Use random_bytes() to generate a random node
2017-09-22 12:26:34 -05:00
Davis Peixoto
0915c7bdc2
173 - Expose UUID versions - Alternative 1
...
https://github.com/ramsey/uuid/issues/173
Creating constants on Uuid object, so they can be used as
- UUID::UUID_TYPE_TIME
- UUID::UUID_TYPE_RANDOM
# Alternative 1
Create constants on Uuid class
Signed-off-by: Davis Peixoto <davis.peixoto@gmail.com >
2017-08-02 08:55:26 -03:00
Davis Peixoto
3d1db97b4d
173 - Expose UUID versions - Alternative 1
...
https://github.com/ramsey/uuid/issues/173
Creating constants on Uuid object, so they can be used as
- Uuid::UUID_TYPE_TIME
- Uuid::UUID_TYPE_RANDOM
Signed-off-by: Davis Peixoto <davis.peixoto@gmail.com >
2017-08-01 15:40:21 -03:00
Martin Hujer
4eefce356d
Optimize UUID string decoding
...
I realized, that 30% of the request time in our app is spent by
hydrating the uuid (We are using Doctrine and in this specific request
I was accidentally hydrating few thousands entities). Luckily, I
remembered the #160 and tried to do similar optimization for uuid
decoding. It resulted in 10-20% performance improvement.
2017-03-26 19:02:20 +02:00
Massimiliano Arione
a2647abc14
add a specific exception for invalid UUID string
2017-03-11 10:52:53 +01:00
Iain Mckay
0a198d3d11
Improves memory usage when generating large quantities of UUID's
2017-03-09 09:01:12 +01:00
Jessica Mauerhan
e80e3d5828
Convert string to lowercase. Fixes GH Issue #131
2016-09-30 16:01:45 -04:00
Ben Ramsey
2e674a1713
Merge pull request #118 from barryvdh/optimized
...
Codec to store UUID in an optimized way for InnoDB
2016-08-02 13:53:14 -04:00
Anton Vasetskiy
879fe3cfe2
Fix RandomNodeProvider: change the max value in mt_rand() call to prevent invalid node generation
2016-07-28 16:44:26 +03:00
Ben Ramsey
e865a0e2ff
Merge branch '107_cache_system_node_provider' of https://github.com/MLoureiro/uuid into MLoureiro-107_cache_system_node_provider
2016-06-24 23:58:19 +02:00
Marcos
ab81ad278a
Remove duplicated call to str_replace()
2016-06-24 20:46:51 +02:00
Marcos
5dbd993b4b
Execute system call only once even if the node is not found
2016-06-23 21:03:07 +02:00
Barry vd. Heuvel
ca0cc642aa
Add OrderedTimeCodec + test
2016-04-27 21:38:55 +02:00
Alex Farcas
c7cf416f23
Implemented timestamp first and timestamp last comb generators
2016-03-22 22:04:05 +02:00
Alex Farcas
ad6f0747bd
Implemented timestamp first and timestamp last comb generators
2016-03-18 16:49:19 +02:00
Ben Ramsey
35247faecf
Drop the use of OpenSSL as a fallback and use paragonie/random_compat
...
Fixes issue #80 for the 3.x series
2016-03-15 11:45:18 -05:00
Ben Ramsey
e4e38b4059
Add random generator for the PECL libsodium extension
2016-02-13 20:29:32 -06:00
frankdejonge
91d0c6da31
Fixes #91 : Made Uuid's serializable.
2015-10-25 22:15:32 +01:00
Emir Beganovic
264a6ceca3
Boolean should be compared strictly
2015-10-07 02:28:06 +02:00