From f42afcecbb24eab14f207b343df1b534f09b3075 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Fri, 21 Feb 2020 11:59:49 -0600 Subject: [PATCH] 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. --- CHANGELOG.md | 7 ++++ .../Number/GenericNumberConverter.php | 4 +-- src/Converter/Time/GenericTimeConverter.php | 14 ++++---- src/Converter/Time/PhpTimeConverter.php | 6 ++-- src/Generator/DceSecurityGenerator.php | 4 +-- .../DceSecurityGeneratorInterface.php | 6 ++-- src/Math/BrickMathCalculator.php | 20 ++++++------ src/Math/CalculatorInterface.php | 18 +++++------ .../Dce/SystemDceSecurityProvider.php | 14 ++++---- src/Provider/DceSecurityProviderInterface.php | 6 ++-- src/Type/{IntegerValue.php => Integer.php} | 2 +- src/Type/Time.php | 14 ++++---- src/Uuid.php | 10 +++--- src/UuidFactory.php | 4 +-- src/UuidFactoryInterface.php | 6 ++-- src/UuidInterface.php | 4 +-- src/functions.php | 6 ++-- tests/FunctionsTest.php | 4 +-- tests/Generator/DceSecurityGeneratorTest.php | 10 +++--- tests/Math/BrickMathCalculatorTest.php | 32 +++++++++---------- .../Dce/SystemDceSecurityProviderTest.php | 10 +++--- .../{IntegerValueTest.php => IntegerTest.php} | 8 ++--- 22 files changed, 109 insertions(+), 100 deletions(-) rename src/Type/{IntegerValue.php => Integer.php} (97%) rename tests/Type/{IntegerValueTest.php => IntegerTest.php} (96%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74308c4..c633464 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/Converter/Number/GenericNumberConverter.php b/src/Converter/Number/GenericNumberConverter.php index cf37b97..4018eaa 100644 --- a/src/Converter/Number/GenericNumberConverter.php +++ b/src/Converter/Number/GenericNumberConverter.php @@ -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); } } diff --git a/src/Converter/Time/GenericTimeConverter.php b/src/Converter/Time/GenericTimeConverter.php index d5ce5f7..be77d12 100644 --- a/src/Converter/Time/GenericTimeConverter.php +++ b/src/Converter/Time/GenericTimeConverter.php @@ -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); diff --git a/src/Converter/Time/PhpTimeConverter.php b/src/Converter/Time/PhpTimeConverter.php index 607102b..28caf22 100644 --- a/src/Converter/Time/PhpTimeConverter.php +++ b/src/Converter/Time/PhpTimeConverter.php @@ -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. diff --git a/src/Generator/DceSecurityGenerator.php b/src/Generator/DceSecurityGenerator.php index c7c08de..5f12a19 100644 --- a/src/Generator/DceSecurityGenerator.php +++ b/src/Generator/DceSecurityGenerator.php @@ -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 { diff --git a/src/Generator/DceSecurityGeneratorInterface.php b/src/Generator/DceSecurityGeneratorInterface.php index b428ff1..faa29a5 100644 --- a/src/Generator/DceSecurityGeneratorInterface.php +++ b/src/Generator/DceSecurityGeneratorInterface.php @@ -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; diff --git a/src/Math/BrickMathCalculator.php b/src/Math/BrickMathCalculator.php index 6d894a9..4e9228b 100644 --- a/src/Math/BrickMathCalculator.php +++ b/src/Math/BrickMathCalculator.php @@ -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); } diff --git a/src/Math/CalculatorInterface.php b/src/Math/CalculatorInterface.php index 2f4bdf0..5271dd6 100644 --- a/src/Math/CalculatorInterface.php +++ b/src/Math/CalculatorInterface.php @@ -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; } diff --git a/src/Provider/Dce/SystemDceSecurityProvider.php b/src/Provider/Dce/SystemDceSecurityProvider.php index 1ee12bd..21a9fab 100644 --- a/src/Provider/Dce/SystemDceSecurityProvider.php +++ b/src/Provider/Dce/SystemDceSecurityProvider.php @@ -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; } diff --git a/src/Provider/DceSecurityProviderInterface.php b/src/Provider/DceSecurityProviderInterface.php index a6174ae..8325da6 100644 --- a/src/Provider/DceSecurityProviderInterface.php +++ b/src/Provider/DceSecurityProviderInterface.php @@ -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; } diff --git a/src/Type/IntegerValue.php b/src/Type/Integer.php similarity index 97% rename from src/Type/IntegerValue.php rename to src/Type/Integer.php index 4735831..a8ff1d8 100644 --- a/src/Type/IntegerValue.php +++ b/src/Type/Integer.php @@ -33,7 +33,7 @@ use function substr; * * @psalm-immutable */ -final class IntegerValue implements NumberInterface +final class Integer implements NumberInterface { /** * @var string diff --git a/src/Type/Time.php b/src/Type/Time.php index ba6de41..3e72d48 100644 --- a/src/Type/Time.php +++ b/src/Type/Time.php @@ -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; } diff --git a/src/Uuid.php b/src/Uuid.php index 40527e6..df3b6ed 100644 --- a/src/Uuid.php +++ b/src/Uuid.php @@ -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 { diff --git a/src/UuidFactory.php b/src/UuidFactory.php index 585b4c5..19a8a7c 100644 --- a/src/UuidFactory.php +++ b/src/UuidFactory.php @@ -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 { diff --git a/src/UuidFactoryInterface.php b/src/UuidFactoryInterface.php index c969d9b..5bcffda 100644 --- a/src/UuidFactoryInterface.php +++ b/src/UuidFactoryInterface.php @@ -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; diff --git a/src/UuidInterface.php b/src/UuidInterface.php index 901aa60..16665ba 100644 --- a/src/UuidInterface.php +++ b/src/UuidInterface.php @@ -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 diff --git a/src/functions.php b/src/functions.php index 3c78651..2eb8f42 100644 --- a/src/functions.php +++ b/src/functions.php @@ -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 { diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index 4babdde..3ce838f 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -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 ); diff --git a/tests/Generator/DceSecurityGeneratorTest.php b/tests/Generator/DceSecurityGeneratorTest.php index 32f9bb3..4961bd5 100644 --- a/tests/Generator/DceSecurityGeneratorTest.php +++ b/tests/Generator/DceSecurityGeneratorTest.php @@ -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', diff --git a/tests/Math/BrickMathCalculatorTest.php b/tests/Math/BrickMathCalculatorTest.php index 1ebda63..73ff73a 100644 --- a/tests/Math/BrickMathCalculatorTest.php +++ b/tests/Math/BrickMathCalculatorTest.php @@ -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); diff --git a/tests/Provider/Dce/SystemDceSecurityProviderTest.php b/tests/Provider/Dce/SystemDceSecurityProviderTest.php index b129289..1ec3c50 100644 --- a/tests/Provider/Dce/SystemDceSecurityProviderTest.php +++ b/tests/Provider/Dce/SystemDceSecurityProviderTest.php @@ -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()); } diff --git a/tests/Type/IntegerValueTest.php b/tests/Type/IntegerTest.php similarity index 96% rename from tests/Type/IntegerValueTest.php rename to tests/Type/IntegerTest.php index fb3c067..83ded79 100644 --- a/tests/Type/IntegerValueTest.php +++ b/tests/Type/IntegerTest.php @@ -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); } /**