Removed some else/elseif and added some early returns to make the code a little easier to read, nothing changes on the big picture

This commit is contained in:
André Filipe
2018-10-17 09:48:21 +01:00
committed by Ben Ramsey
parent f1e27fc9e8
commit 84fe6cf755
4 changed files with 33 additions and 25 deletions
-1
View File
@@ -19,5 +19,4 @@ namespace Ramsey\Uuid\Codec;
*/
class TimestampLastCombCodec extends StringCodec
{
}
@@ -43,7 +43,8 @@ class BigNumberTimeConverter implements TimeConverterInterface
$usec = new BigNumber($microSeconds);
$usec->multiply('10');
$uuidTime->add($sec)
$uuidTime
->add($sec)
->add($usec)
->add('122192928000000000');
+3 -1
View File
@@ -289,7 +289,9 @@ class FeatureSet
{
if ($this->is64BitSystem()) {
return new PhpTimeConverter();
} elseif ($this->hasBigNumber()) {
}
if ($this->hasBigNumber()) {
return new BigNumberTimeConverter();
}
+28 -22
View File
@@ -246,28 +246,32 @@ class Uuid implements UuidInterface
public function compareTo(UuidInterface $other)
{
$comparison = 0;
if ($this->getMostSignificantBitsHex() < $other->getMostSignificantBitsHex()) {
$comparison = -1;
} elseif ($this->getMostSignificantBitsHex() > $other->getMostSignificantBitsHex()) {
$comparison = 1;
} elseif ($this->getLeastSignificantBitsHex() < $other->getLeastSignificantBitsHex()) {
$comparison = -1;
} elseif ($this->getLeastSignificantBitsHex() > $other->getLeastSignificantBitsHex()) {
$comparison = 1;
return -1;
}
return $comparison;
if ($this->getMostSignificantBitsHex() > $other->getMostSignificantBitsHex()) {
return 1;
}
if ($this->getLeastSignificantBitsHex() < $other->getLeastSignificantBitsHex()) {
return -1;
}
if ($this->getLeastSignificantBitsHex() > $other->getLeastSignificantBitsHex()) {
return 1;
}
return 0;
}
public function equals($other)
{
if (!($other instanceof UuidInterface)) {
if (!$other instanceof UuidInterface) {
return false;
}
return ($this->compareTo($other) == 0);
return $this->compareTo($other) == 0;
}
public function getBytes()
@@ -324,8 +328,7 @@ class Uuid implements UuidInterface
*/
public function getClockSequence()
{
return (($this->getClockSeqHiAndReserved() & 0x3f) << 8)
| $this->getClockSeqLow();
return ($this->getClockSeqHiAndReserved() & 0x3f) << 8 | $this->getClockSeqLow();
}
public function getClockSequenceHex()
@@ -573,17 +576,20 @@ class Uuid implements UuidInterface
public function getVariant()
{
$clockSeq = $this->getClockSeqHiAndReserved();
if (0 === ($clockSeq & 0x80)) {
$variant = self::RESERVED_NCS;
} elseif (0 === ($clockSeq & 0x40)) {
$variant = self::RFC_4122;
} elseif (0 === ($clockSeq & 0x20)) {
$variant = self::RESERVED_MICROSOFT;
} else {
$variant = self::RESERVED_FUTURE;
return self::RESERVED_NCS;
}
return $variant;
if (0 === ($clockSeq & 0x40)) {
return self::RFC_4122;
}
if (0 === ($clockSeq & 0x20)) {
return self::RESERVED_MICROSOFT;
}
return self::RESERVED_FUTURE;
}
public function getVersion()