mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
Rename Type\IntegerValue to Type\Integer
Rename `Type\IntegerValue` to `Type\Integer`. It was originally named `IntegerValue` because static analysis sees `Integer` in docblock annotations and treats it as the native `int` type. `Integer` is not a reserved word in PHP, so it should be named `Integer` for consistency with other types in this library. When using it, a class alias prevents static analysis from complaining.
This commit is contained in:
@@ -12,6 +12,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
||||
|
||||
### Changed
|
||||
|
||||
* Rename `Type\IntegerValue` to `Type\Integer`. It was originally named
|
||||
`IntegerValue` because static analysis sees `Integer` in docblock annotations
|
||||
and treats it as the native `int` type. `Integer` is not a reserved word in
|
||||
PHP, so it should be named `Integer` for consistency with other types in this
|
||||
library. When using it, a class alias prevents static analysis from
|
||||
complaining.
|
||||
|
||||
### Deprecated
|
||||
|
||||
### Removed
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Ramsey\Uuid\Converter\Number;
|
||||
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Math\CalculatorInterface;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
/**
|
||||
* GenericNumberConverter uses the provided calculate to convert decimal
|
||||
@@ -55,6 +55,6 @@ class GenericNumberConverter implements NumberConverterInterface
|
||||
*/
|
||||
public function toHex(string $number): string
|
||||
{
|
||||
return $this->calculator->toBase(new IntegerValue($number), 16);
|
||||
return $this->calculator->toBase(new IntegerObject($number), 16);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\Math\CalculatorInterface;
|
||||
use Ramsey\Uuid\Math\RoundingMode;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
|
||||
use function explode;
|
||||
@@ -52,19 +52,19 @@ class GenericTimeConverter implements TimeConverterInterface
|
||||
|
||||
$sec = $this->calculator->multiply(
|
||||
$timestamp->getSeconds(),
|
||||
new IntegerValue('10000000')
|
||||
new IntegerObject('10000000')
|
||||
);
|
||||
|
||||
$usec = $this->calculator->multiply(
|
||||
$timestamp->getMicroSeconds(),
|
||||
new IntegerValue('10')
|
||||
new IntegerObject('10')
|
||||
);
|
||||
|
||||
/** @var IntegerValue $uuidTime */
|
||||
/** @var IntegerObject $uuidTime */
|
||||
$uuidTime = $this->calculator->add(
|
||||
$sec,
|
||||
$usec,
|
||||
new IntegerValue('122192928000000000')
|
||||
new IntegerObject('122192928000000000')
|
||||
);
|
||||
|
||||
$uuidTimeHex = str_pad(
|
||||
@@ -89,14 +89,14 @@ class GenericTimeConverter implements TimeConverterInterface
|
||||
// which also includes the microtime.
|
||||
$epochNanoseconds = $this->calculator->subtract(
|
||||
$this->calculator->toIntegerValue($uuidTimestamp),
|
||||
new IntegerValue('122192928000000000')
|
||||
new IntegerObject('122192928000000000')
|
||||
);
|
||||
|
||||
$unixTimestamp = $this->calculator->divide(
|
||||
RoundingMode::HALF_UP,
|
||||
6,
|
||||
$epochNanoseconds,
|
||||
new IntegerValue('10000000')
|
||||
new IntegerObject('10000000')
|
||||
);
|
||||
|
||||
$split = explode('.', (string) $unixTimestamp, 2);
|
||||
|
||||
@@ -18,7 +18,7 @@ use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
use Ramsey\Uuid\Math\CalculatorInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
|
||||
use function count;
|
||||
@@ -77,8 +77,8 @@ class PhpTimeConverter implements TimeConverterInterface
|
||||
*/
|
||||
public function calculateTime(string $seconds, string $microSeconds): Hexadecimal
|
||||
{
|
||||
$seconds = new IntegerValue($seconds);
|
||||
$microSeconds = new IntegerValue($microSeconds);
|
||||
$seconds = new IntegerObject($seconds);
|
||||
$microSeconds = new IntegerObject($microSeconds);
|
||||
|
||||
// 0x01b21dd213814000 is the number of 100-nanosecond intervals between the
|
||||
// UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
|
||||
|
||||
@@ -18,7 +18,7 @@ use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Provider\DceSecurityProviderInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
use function hex2bin;
|
||||
@@ -68,7 +68,7 @@ class DceSecurityGenerator implements DceSecurityGeneratorInterface
|
||||
|
||||
public function generate(
|
||||
int $localDomain,
|
||||
?IntegerValue $localIdentifier = null,
|
||||
?IntegerObject $localIdentifier = null,
|
||||
?Hexadecimal $node = null,
|
||||
?int $clockSeq = null
|
||||
): string {
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Ramsey\Uuid\Generator;
|
||||
|
||||
use Ramsey\Uuid\Rfc4122\UuidV2;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
/**
|
||||
* A DCE Security generator generates strings of binary data based on a local
|
||||
@@ -32,7 +32,7 @@ interface DceSecurityGeneratorInterface
|
||||
*
|
||||
* @param int $localDomain The local domain to use when generating bytes,
|
||||
* according to DCE Security
|
||||
* @param IntegerValue|null $localIdentifier The local identifier for the
|
||||
* @param IntegerObject|null $localIdentifier The local identifier for the
|
||||
* given domain; this may be a UID or GID on POSIX systems, if the local
|
||||
* domain is person or group, or it may be a site-defined identifier
|
||||
* if the local domain is org
|
||||
@@ -46,7 +46,7 @@ interface DceSecurityGeneratorInterface
|
||||
*/
|
||||
public function generate(
|
||||
int $localDomain,
|
||||
?IntegerValue $localIdentifier = null,
|
||||
?IntegerObject $localIdentifier = null,
|
||||
?Hexadecimal $node = null,
|
||||
?int $clockSeq = null
|
||||
): string;
|
||||
|
||||
@@ -21,7 +21,7 @@ use Brick\Math\RoundingMode as BrickMathRounding;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Type\Decimal;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\NumberInterface;
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ final class BrickMathCalculator implements CalculatorInterface
|
||||
$sum = $sum->plus($addend->toString());
|
||||
}
|
||||
|
||||
return new IntegerValue((string) $sum);
|
||||
return new IntegerObject((string) $sum);
|
||||
}
|
||||
|
||||
public function subtract(NumberInterface $minuend, NumberInterface ...$subtrahends): NumberInterface
|
||||
@@ -63,7 +63,7 @@ final class BrickMathCalculator implements CalculatorInterface
|
||||
$difference = $difference->minus($subtrahend->toString());
|
||||
}
|
||||
|
||||
return new IntegerValue((string) $difference);
|
||||
return new IntegerObject((string) $difference);
|
||||
}
|
||||
|
||||
public function multiply(NumberInterface $multiplicand, NumberInterface ...$multipliers): NumberInterface
|
||||
@@ -74,7 +74,7 @@ final class BrickMathCalculator implements CalculatorInterface
|
||||
$product = $product->multipliedBy($multiplier->toString());
|
||||
}
|
||||
|
||||
return new IntegerValue((string) $product);
|
||||
return new IntegerObject((string) $product);
|
||||
}
|
||||
|
||||
public function divide(
|
||||
@@ -92,16 +92,16 @@ final class BrickMathCalculator implements CalculatorInterface
|
||||
}
|
||||
|
||||
if ($scale === 0) {
|
||||
return new IntegerValue((string) $quotient->toBigInteger());
|
||||
return new IntegerObject((string) $quotient->toBigInteger());
|
||||
}
|
||||
|
||||
return new Decimal((string) $quotient);
|
||||
}
|
||||
|
||||
public function fromBase(string $value, int $base): IntegerValue
|
||||
public function fromBase(string $value, int $base): IntegerObject
|
||||
{
|
||||
try {
|
||||
return new IntegerValue((string) BigInteger::fromBase($value, $base));
|
||||
return new IntegerObject((string) BigInteger::fromBase($value, $base));
|
||||
} catch (MathException $exception) {
|
||||
throw new InvalidArgumentException(
|
||||
$exception->getMessage(),
|
||||
@@ -111,7 +111,7 @@ final class BrickMathCalculator implements CalculatorInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function toBase(IntegerValue $value, int $base): string
|
||||
public function toBase(IntegerObject $value, int $base): string
|
||||
{
|
||||
try {
|
||||
return BigInteger::of($value->toString())->toBase($base);
|
||||
@@ -124,12 +124,12 @@ final class BrickMathCalculator implements CalculatorInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function toHexadecimal(IntegerValue $value): Hexadecimal
|
||||
public function toHexadecimal(IntegerObject $value): Hexadecimal
|
||||
{
|
||||
return new Hexadecimal($this->toBase($value, 16));
|
||||
}
|
||||
|
||||
public function toIntegerValue(Hexadecimal $value): IntegerValue
|
||||
public function toIntegerValue(Hexadecimal $value): IntegerObject
|
||||
{
|
||||
return $this->fromBase($value->toString(), 16);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Math;
|
||||
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\NumberInterface;
|
||||
|
||||
/**
|
||||
@@ -80,27 +80,27 @@ interface CalculatorInterface
|
||||
* @param string $value The value to convert
|
||||
* @param int $base The base to convert from (i.e., 2, 16, 32, etc.)
|
||||
*
|
||||
* @return IntegerValue The base-10 integer value of the converted value
|
||||
* @return IntegerObject The base-10 integer value of the converted value
|
||||
*/
|
||||
public function fromBase(string $value, int $base): IntegerValue;
|
||||
public function fromBase(string $value, int $base): IntegerObject;
|
||||
|
||||
/**
|
||||
* Converts a base-10 integer value to an arbitrary base
|
||||
*
|
||||
* @param IntegerValue $value The integer value to convert
|
||||
* @param IntegerObject $value The integer value to convert
|
||||
* @param int $base The base to convert to (i.e., 2, 16, 32, etc.)
|
||||
*
|
||||
* @return string The value represented in the specified base
|
||||
*/
|
||||
public function toBase(IntegerValue $value, int $base): string;
|
||||
public function toBase(IntegerObject $value, int $base): string;
|
||||
|
||||
/**
|
||||
* Converts an IntegerValue instance to a Hexadecimal instance
|
||||
* Converts an Integer instance to a Hexadecimal instance
|
||||
*/
|
||||
public function toHexadecimal(IntegerValue $value): Hexadecimal;
|
||||
public function toHexadecimal(IntegerObject $value): Hexadecimal;
|
||||
|
||||
/**
|
||||
* Converts a Hexadecimal instance to an IntegerValue instance
|
||||
* Converts a Hexadecimal instance to an Integer instance
|
||||
*/
|
||||
public function toIntegerValue(Hexadecimal $value): IntegerValue;
|
||||
public function toIntegerValue(Hexadecimal $value): IntegerObject;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Ramsey\Uuid\Provider\Dce;
|
||||
|
||||
use Ramsey\Uuid\Exception\DceSecurityException;
|
||||
use Ramsey\Uuid\Provider\DceSecurityProviderInterface;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
use function escapeshellarg;
|
||||
use function preg_split;
|
||||
@@ -40,11 +40,11 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUid(): IntegerValue
|
||||
public function getUid(): IntegerObject
|
||||
{
|
||||
static $uid = null;
|
||||
|
||||
if ($uid instanceof IntegerValue) {
|
||||
if ($uid instanceof IntegerObject) {
|
||||
return $uid;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
$uid = new IntegerValue($uid);
|
||||
$uid = new IntegerObject($uid);
|
||||
|
||||
return $uid;
|
||||
}
|
||||
@@ -70,11 +70,11 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getGid(): IntegerValue
|
||||
public function getGid(): IntegerObject
|
||||
{
|
||||
static $gid = null;
|
||||
|
||||
if ($gid instanceof IntegerValue) {
|
||||
if ($gid instanceof IntegerObject) {
|
||||
return $gid;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class SystemDceSecurityProvider implements DceSecurityProviderInterface
|
||||
);
|
||||
}
|
||||
|
||||
$gid = new IntegerValue($gid);
|
||||
$gid = new IntegerObject($gid);
|
||||
|
||||
return $gid;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Provider;
|
||||
|
||||
use Ramsey\Uuid\Rfc4122\UuidV2;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
/**
|
||||
* A DCE provider provides access to local domain identifiers for version 2,
|
||||
@@ -30,12 +30,12 @@ interface DceSecurityProviderInterface
|
||||
*
|
||||
* @link https://en.wikipedia.org/wiki/User_identifier User identifier
|
||||
*/
|
||||
public function getUid(): IntegerValue;
|
||||
public function getUid(): IntegerObject;
|
||||
|
||||
/**
|
||||
* Returns a group identifier for the system
|
||||
*
|
||||
* @link https://en.wikipedia.org/wiki/Group_identifier Group identifier
|
||||
*/
|
||||
public function getGid(): IntegerValue;
|
||||
public function getGid(): IntegerObject;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use function substr;
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class IntegerValue implements NumberInterface
|
||||
final class Integer implements NumberInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
+8
-6
@@ -14,6 +14,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Type;
|
||||
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
/**
|
||||
* A value object representing a timestamp
|
||||
*
|
||||
@@ -26,12 +28,12 @@ namespace Ramsey\Uuid\Type;
|
||||
final class Time
|
||||
{
|
||||
/**
|
||||
* @var IntegerValue
|
||||
* @var IntegerObject
|
||||
*/
|
||||
private $seconds;
|
||||
|
||||
/**
|
||||
* @var IntegerValue
|
||||
* @var IntegerObject
|
||||
*/
|
||||
private $microSeconds;
|
||||
|
||||
@@ -41,16 +43,16 @@ final class Time
|
||||
*/
|
||||
public function __construct($seconds, $microSeconds = 0)
|
||||
{
|
||||
$this->seconds = new IntegerValue($seconds);
|
||||
$this->microSeconds = new IntegerValue($microSeconds);
|
||||
$this->seconds = new IntegerObject($seconds);
|
||||
$this->microSeconds = new IntegerObject($microSeconds);
|
||||
}
|
||||
|
||||
public function getSeconds(): IntegerValue
|
||||
public function getSeconds(): IntegerObject
|
||||
{
|
||||
return $this->seconds;
|
||||
}
|
||||
|
||||
public function getMicroSeconds(): IntegerValue
|
||||
public function getMicroSeconds(): IntegerObject
|
||||
{
|
||||
return $this->microSeconds;
|
||||
}
|
||||
|
||||
+5
-5
@@ -21,7 +21,7 @@ use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
use Ramsey\Uuid\Fields\FieldsInterface;
|
||||
use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
use function str_replace;
|
||||
use function strcmp;
|
||||
@@ -309,9 +309,9 @@ class Uuid implements UuidInterface
|
||||
return new Hexadecimal(str_replace('-', '', $this->toString()));
|
||||
}
|
||||
|
||||
public function getInteger(): IntegerValue
|
||||
public function getInteger(): IntegerObject
|
||||
{
|
||||
return new IntegerValue($this->numberConverter->fromHex($this->getHex()->toString()));
|
||||
return new IntegerObject($this->numberConverter->fromHex($this->getHex()->toString()));
|
||||
}
|
||||
|
||||
/** @psalm-return non-empty-string */
|
||||
@@ -451,7 +451,7 @@ class Uuid implements UuidInterface
|
||||
*
|
||||
* @param int $localDomain The local domain to use when generating bytes,
|
||||
* according to DCE Security
|
||||
* @param IntegerValue|null $localIdentifier The local identifier for the
|
||||
* @param IntegerObject|null $localIdentifier The local identifier for the
|
||||
* given domain; this may be a UID or GID on POSIX systems, if the local
|
||||
* domain is person or group, or it may be a site-defined identifier
|
||||
* if the local domain is org
|
||||
@@ -466,7 +466,7 @@ class Uuid implements UuidInterface
|
||||
*/
|
||||
public static function uuid2(
|
||||
int $localDomain,
|
||||
?IntegerValue $localIdentifier = null,
|
||||
?IntegerObject $localIdentifier = null,
|
||||
?Hexadecimal $node = null,
|
||||
?int $clockSeq = null
|
||||
): UuidInterface {
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ use Ramsey\Uuid\Generator\TimeGeneratorInterface;
|
||||
use Ramsey\Uuid\Provider\NodeProviderInterface;
|
||||
use Ramsey\Uuid\Provider\Time\FixedTimeProvider;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
use Ramsey\Uuid\Validator\ValidatorInterface;
|
||||
|
||||
@@ -314,7 +314,7 @@ class UuidFactory implements UuidFactoryInterface
|
||||
|
||||
public function uuid2(
|
||||
int $localDomain,
|
||||
?IntegerValue $localIdentifier = null,
|
||||
?IntegerObject $localIdentifier = null,
|
||||
?Hexadecimal $node = null,
|
||||
?int $clockSeq = null
|
||||
): UuidInterface {
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Ramsey\Uuid;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Validator\ValidatorInterface;
|
||||
|
||||
/**
|
||||
@@ -53,7 +53,7 @@ interface UuidFactoryInterface
|
||||
*
|
||||
* @param int $localDomain The local domain to use when generating bytes,
|
||||
* according to DCE Security
|
||||
* @param IntegerValue|null $localIdentifier The local identifier for the
|
||||
* @param IntegerObject|null $localIdentifier The local identifier for the
|
||||
* given domain; this may be a UID or GID on POSIX systems, if the local
|
||||
* domain is person or group, or it may be a site-defined identifier
|
||||
* if the local domain is org
|
||||
@@ -68,7 +68,7 @@ interface UuidFactoryInterface
|
||||
*/
|
||||
public function uuid2(
|
||||
int $localDomain,
|
||||
?IntegerValue $localIdentifier = null,
|
||||
?IntegerObject $localIdentifier = null,
|
||||
?Hexadecimal $node = null,
|
||||
?int $clockSeq = null
|
||||
): UuidInterface;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Ramsey\Uuid;
|
||||
use JsonSerializable;
|
||||
use Ramsey\Uuid\Fields\FieldsInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Serializable;
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ interface UuidInterface extends
|
||||
/**
|
||||
* Returns the integer value of the UUID as a string
|
||||
*/
|
||||
public function getInteger(): IntegerValue;
|
||||
public function getInteger(): IntegerObject;
|
||||
|
||||
/**
|
||||
* Returns a string representation of the UUID
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid;
|
||||
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
/**
|
||||
* Returns a version 1 (time-based) UUID from a host ID, sequence number,
|
||||
@@ -39,7 +39,7 @@ function v1($node = null, ?int $clockSeq = null): string
|
||||
*
|
||||
* @param int $localDomain The local domain to use when generating bytes,
|
||||
* according to DCE Security
|
||||
* @param IntegerValue|null $localIdentifier The local identifier for the
|
||||
* @param IntegerObject|null $localIdentifier The local identifier for the
|
||||
* given domain; this may be a UID or GID on POSIX systems, if the local
|
||||
* domain is person or group, or it may be a site-defined identifier
|
||||
* if the local domain is org
|
||||
@@ -51,7 +51,7 @@ function v1($node = null, ?int $clockSeq = null): string
|
||||
*/
|
||||
function v2(
|
||||
int $localDomain,
|
||||
?IntegerValue $localIdentifier = null,
|
||||
?IntegerObject $localIdentifier = null,
|
||||
?Hexadecimal $node = null,
|
||||
?int $clockSeq = null
|
||||
): string {
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Ramsey\Uuid\Test;
|
||||
|
||||
use Ramsey\Uuid\Rfc4122\FieldsInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
use function Ramsey\Uuid\v1;
|
||||
@@ -29,7 +29,7 @@ class FunctionsTest extends TestCase
|
||||
{
|
||||
$v2 = v2(
|
||||
Uuid::DCE_DOMAIN_PERSON,
|
||||
new IntegerValue('1004'),
|
||||
new IntegerObject('1004'),
|
||||
new Hexadecimal('aabbccdd0011'),
|
||||
1234
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ use Ramsey\Uuid\Provider\NodeProviderInterface;
|
||||
use Ramsey\Uuid\Provider\Time\FixedTimeProvider;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
@@ -42,7 +42,7 @@ class DceSecurityGeneratorTest extends TestCase
|
||||
$seconds,
|
||||
$microseconds,
|
||||
int $providedDomain,
|
||||
?IntegerValue $providedId,
|
||||
?IntegerObject $providedId,
|
||||
?Hexadecimal $providedNode,
|
||||
?int $providedClockSeq,
|
||||
string $expectedId,
|
||||
@@ -51,8 +51,8 @@ class DceSecurityGeneratorTest extends TestCase
|
||||
string $expectedTimeMidHi
|
||||
): void {
|
||||
$dceSecurityProvider = Mockery::mock(DceSecurityProviderInterface::class, [
|
||||
'getUid' => new IntegerValue($uid),
|
||||
'getGid' => new IntegerValue($gid),
|
||||
'getUid' => new IntegerObject($uid),
|
||||
'getGid' => new IntegerObject($gid),
|
||||
]);
|
||||
|
||||
$nodeProvider = Mockery::mock(NodeProviderInterface::class, [
|
||||
@@ -119,7 +119,7 @@ class DceSecurityGeneratorTest extends TestCase
|
||||
'seconds' => 1579132397,
|
||||
'microseconds' => 500000,
|
||||
'providedDomain' => Uuid::DCE_DOMAIN_ORG,
|
||||
'providedId' => new IntegerValue('4294967295'),
|
||||
'providedId' => new IntegerObject('4294967295'),
|
||||
'providedNode' => null,
|
||||
'providedClockSeq' => null,
|
||||
'expectedId' => 'ffffffff',
|
||||
|
||||
@@ -8,15 +8,15 @@ use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
use Ramsey\Uuid\Math\RoundingMode;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
class BrickMathCalculatorTest extends TestCase
|
||||
{
|
||||
public function testAdd(): void
|
||||
{
|
||||
$int1 = new IntegerValue(5);
|
||||
$int2 = new IntegerValue(6);
|
||||
$int3 = new IntegerValue(7);
|
||||
$int1 = new IntegerObject(5);
|
||||
$int2 = new IntegerObject(6);
|
||||
$int3 = new IntegerObject(7);
|
||||
|
||||
$calculator = new BrickMathCalculator();
|
||||
|
||||
@@ -27,9 +27,9 @@ class BrickMathCalculatorTest extends TestCase
|
||||
|
||||
public function testSubtract(): void
|
||||
{
|
||||
$int1 = new IntegerValue(5);
|
||||
$int2 = new IntegerValue(6);
|
||||
$int3 = new IntegerValue(7);
|
||||
$int1 = new IntegerObject(5);
|
||||
$int2 = new IntegerObject(6);
|
||||
$int3 = new IntegerObject(7);
|
||||
|
||||
$calculator = new BrickMathCalculator();
|
||||
|
||||
@@ -40,9 +40,9 @@ class BrickMathCalculatorTest extends TestCase
|
||||
|
||||
public function testMultiply(): void
|
||||
{
|
||||
$int1 = new IntegerValue(5);
|
||||
$int2 = new IntegerValue(6);
|
||||
$int3 = new IntegerValue(7);
|
||||
$int1 = new IntegerObject(5);
|
||||
$int2 = new IntegerObject(6);
|
||||
$int3 = new IntegerObject(7);
|
||||
|
||||
$calculator = new BrickMathCalculator();
|
||||
|
||||
@@ -53,9 +53,9 @@ class BrickMathCalculatorTest extends TestCase
|
||||
|
||||
public function testDivide(): void
|
||||
{
|
||||
$int1 = new IntegerValue(1023);
|
||||
$int2 = new IntegerValue(6);
|
||||
$int3 = new IntegerValue(7);
|
||||
$int1 = new IntegerObject(1023);
|
||||
$int2 = new IntegerObject(6);
|
||||
$int3 = new IntegerObject(7);
|
||||
|
||||
$calculator = new BrickMathCalculator();
|
||||
|
||||
@@ -70,13 +70,13 @@ class BrickMathCalculatorTest extends TestCase
|
||||
|
||||
$result = $calculator->fromBase('ffffffffffffffffffff', 16);
|
||||
|
||||
$this->assertInstanceOf(IntegerValue::class, $result);
|
||||
$this->assertInstanceOf(IntegerObject::class, $result);
|
||||
$this->assertSame('1208925819614629174706175', $result->toString());
|
||||
}
|
||||
|
||||
public function testToBase(): void
|
||||
{
|
||||
$intValue = new IntegerValue('1208925819614629174706175');
|
||||
$intValue = new IntegerObject('1208925819614629174706175');
|
||||
$calculator = new BrickMathCalculator();
|
||||
|
||||
$this->assertSame('ffffffffffffffffffff', $calculator->toBase($intValue, 16));
|
||||
@@ -84,7 +84,7 @@ class BrickMathCalculatorTest extends TestCase
|
||||
|
||||
public function testToHexadecimal(): void
|
||||
{
|
||||
$intValue = new IntegerValue('1208925819614629174706175');
|
||||
$intValue = new IntegerObject('1208925819614629174706175');
|
||||
$calculator = new BrickMathCalculator();
|
||||
|
||||
$result = $calculator->toHexadecimal($intValue);
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Ramsey\Uuid\Test\Provider\Dce;
|
||||
use Ramsey\Uuid\Exception\DceSecurityException;
|
||||
use Ramsey\Uuid\Provider\Dce\SystemDceSecurityProvider;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use phpmock\mockery\PHPMockery;
|
||||
|
||||
use function array_merge;
|
||||
@@ -146,7 +146,7 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
|
||||
$uid = $provider->getUid();
|
||||
|
||||
$this->assertInstanceOf(IntegerValue::class, $uid);
|
||||
$this->assertInstanceOf(IntegerObject::class, $uid);
|
||||
$this->assertSame($expectedId, $uid->toString());
|
||||
$this->assertSame($uid, $provider->getUid());
|
||||
}
|
||||
@@ -198,7 +198,7 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
|
||||
$uid = $provider->getUid();
|
||||
|
||||
$this->assertInstanceOf(IntegerValue::class, $uid);
|
||||
$this->assertInstanceOf(IntegerObject::class, $uid);
|
||||
$this->assertSame($id, $uid->toString());
|
||||
$this->assertSame($uid, $provider->getUid());
|
||||
}
|
||||
@@ -297,7 +297,7 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
|
||||
$gid = $provider->getGid();
|
||||
|
||||
$this->assertInstanceOf(IntegerValue::class, $gid);
|
||||
$this->assertInstanceOf(IntegerObject::class, $gid);
|
||||
$this->assertSame($id, $gid->toString());
|
||||
$this->assertSame($gid, $provider->getGid());
|
||||
}
|
||||
@@ -418,7 +418,7 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
|
||||
$gid = $provider->getGid();
|
||||
|
||||
$this->assertInstanceOf(IntegerValue::class, $gid);
|
||||
$this->assertInstanceOf(IntegerObject::class, $gid);
|
||||
$this->assertSame($expectedId, $gid->toString());
|
||||
$this->assertSame($gid, $provider->getGid());
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace Ramsey\Uuid\Test\Type;
|
||||
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
|
||||
class IntegerValueTest extends TestCase
|
||||
class IntegerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param int|float|string $value
|
||||
@@ -17,7 +17,7 @@ class IntegerValueTest extends TestCase
|
||||
*/
|
||||
public function testIntegerValueType($value, string $expected): void
|
||||
{
|
||||
$integer = new IntegerValue($value);
|
||||
$integer = new IntegerObject($value);
|
||||
|
||||
$this->assertSame($expected, $integer->toString());
|
||||
$this->assertSame($expected, (string) $integer);
|
||||
@@ -141,7 +141,7 @@ class IntegerValueTest extends TestCase
|
||||
. 'digits 0-9 and, optionally, a sign (+ or -)'
|
||||
);
|
||||
|
||||
new IntegerValue($value);
|
||||
new IntegerObject($value);
|
||||
}
|
||||
|
||||
/**
|
||||
Reference in New Issue
Block a user