Remove CalculatorInterface as a Uuid constructor parameter

This commit is contained in:
Ben Ramsey
2020-01-13 11:09:35 -06:00
parent 52f764c284
commit 2ad77d9ca7
13 changed files with 26 additions and 101 deletions
+2 -12
View File
@@ -22,7 +22,6 @@ use Ramsey\Uuid\Converter\TimeConverterInterface;
use Ramsey\Uuid\Exception\DateTimeException;
use Ramsey\Uuid\Exception\UnsupportedOperationException;
use Ramsey\Uuid\Fields\FieldsInterface;
use Ramsey\Uuid\Math\CalculatorInterface;
use Ramsey\Uuid\Rfc4122\FieldsInterface as Rfc4122FieldsInterface;
/**
@@ -170,11 +169,6 @@ class Uuid implements UuidInterface
*/
protected $timeConverter;
/**
* @var CalculatorInterface
*/
protected $calculator;
/**
* Creates a universally unique identifier (UUID) from an array of fields
*
@@ -198,21 +192,17 @@ class Uuid implements UuidInterface
* UUID strings
* @param TimeConverterInterface $timeConverter The time converter to use
* for converting timestamps extracted from a UUID to unix timestamps
* @param CalculatorInterface $calculator The calculator to use for performing
* mathematical operations on UUIDs
*/
public function __construct(
Rfc4122FieldsInterface $fields,
NumberConverterInterface $numberConverter,
CodecInterface $codec,
TimeConverterInterface $timeConverter,
CalculatorInterface $calculator
TimeConverterInterface $timeConverter
) {
$this->fields = $fields;
$this->codec = $codec;
$this->numberConverter = $numberConverter;
$this->timeConverter = $timeConverter;
$this->calculator = $calculator;
}
public function __toString(): string
@@ -376,7 +366,7 @@ class Uuid implements UuidInterface
}
$unixTime = $this->timeConverter->convertTime(
$this->calculator->toIntegerValue($this->fields->getTimestamp())->toString()
$this->numberConverter->fromHex($this->fields->getTimestamp()->toString())
);
try {