-
-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,499 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the ramsey/uuid library | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> | ||
* @license http://opensource.org/licenses/MIT MIT | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Ramsey\Uuid\Builder; | ||
|
||
use Ramsey\Uuid\Codec\CodecInterface; | ||
use Ramsey\Uuid\Converter\NumberConverterInterface; | ||
use Ramsey\Uuid\Converter\TimeConverterInterface; | ||
use Ramsey\Uuid\Guid; | ||
use Ramsey\Uuid\UuidInterface; | ||
|
||
/** | ||
* GuidBuilder builds instances of Guid | ||
* | ||
* @psalm-immutable | ||
*/ | ||
class GuidBuilder implements UuidBuilderInterface | ||
{ | ||
/** | ||
* @var NumberConverterInterface | ||
*/ | ||
private $numberConverter; | ||
|
||
/** | ||
* @var TimeConverterInterface | ||
*/ | ||
private $timeConverter; | ||
|
||
/** | ||
* @param NumberConverterInterface $numberConverter The number converter to | ||
* use when constructing the Guid | ||
* @param TimeConverterInterface $timeConverter The time converter to use | ||
* for converting timestamps extracted from a UUID to Unix timestamps | ||
*/ | ||
public function __construct( | ||
NumberConverterInterface $numberConverter, | ||
TimeConverterInterface $timeConverter | ||
) { | ||
$this->numberConverter = $numberConverter; | ||
$this->timeConverter = $timeConverter; | ||
} | ||
|
||
/** | ||
* Builds and returns a Guid | ||
* | ||
* @param CodecInterface $codec The codec to use for building this Guid instance | ||
* @param string[] $fields An array of fields from which to construct a Guid instance; | ||
* see {@see \Ramsey\Uuid\UuidInterface::getFieldsHex()} for array structure. | ||
* | ||
* @return Guid The GuidBuilder returns an instance of Ramsey\Uuid\Guid | ||
*/ | ||
public function build(CodecInterface $codec, array $fields): UuidInterface | ||
{ | ||
return new Guid( | ||
$fields, | ||
$this->numberConverter, | ||
$codec, | ||
$this->timeConverter | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.