| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This file is part of the ramsey/uuid library |
| 5 |
* |
| 6 |
* For the full copyright and license information, please view the LICENSE |
| 7 |
* file that was distributed with this source code. |
| 8 |
* |
| 9 |
* @copyright Copyright (c) Ben Ramsey <[email protected]> |
| 10 |
* @license http://opensource.org/licenses/MIT MIT |
| 11 |
*/ |
| 12 |
declare (strict_types=1); |
| 13 |
namespace Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Builder; |
| 14 |
|
| 15 |
use Dudlewebs\WPMCS\GCP\Ramsey\Collection\AbstractCollection; |
| 16 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Converter\Number\GenericNumberConverter; |
| 17 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Converter\Time\GenericTimeConverter; |
| 18 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Converter\Time\PhpTimeConverter; |
| 19 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Guid\GuidBuilder; |
| 20 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Math\BrickMathCalculator; |
| 21 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Nonstandard\UuidBuilder as NonstandardUuidBuilder; |
| 22 |
use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Rfc4122\UuidBuilder as Rfc4122UuidBuilder; |
| 23 |
use Traversable; |
| 24 |
/** |
| 25 |
* A collection of UuidBuilderInterface objects |
| 26 |
* |
| 27 |
* @deprecated this class has been deprecated and will be removed in 5.0.0. The use-case for this class comes from a |
| 28 |
* pre-`phpstan/phpstan` and pre-`vimeo/psalm` ecosystem, in which type safety had to be mostly enforced at runtime: |
| 29 |
* that is no longer necessary, now that you can safely verify your code to be correct, and use more generic types |
| 30 |
* like `iterable<T>` instead. |
| 31 |
* |
| 32 |
* @extends AbstractCollection<UuidBuilderInterface> |
| 33 |
*/ |
| 34 |
class BuilderCollection extends AbstractCollection |
| 35 |
{ |
| 36 |
public function getType() : string |
| 37 |
{ |
| 38 |
return UuidBuilderInterface::class; |
| 39 |
} |
| 40 |
public function getIterator() : Traversable |
| 41 |
{ |
| 42 |
return parent::getIterator(); |
| 43 |
} |
| 44 |
/** |
| 45 |
* Re-constructs the object from its serialized form |
| 46 |
* |
| 47 |
* @param string $serialized The serialized PHP string to unserialize into a UuidInterface instance |
| 48 |
*/ |
| 49 |
public function unserialize($serialized) : void |
| 50 |
{ |
| 51 |
/** @var array<array-key, UuidBuilderInterface> $data */ |
| 52 |
$data = \unserialize($serialized, ['allowed_classes' => [BrickMathCalculator::class, GenericNumberConverter::class, GenericTimeConverter::class, GuidBuilder::class, NonstandardUuidBuilder::class, PhpTimeConverter::class, Rfc4122UuidBuilder::class]]); |
| 53 |
$this->data = \array_filter($data, function ($unserialized) : bool { |
| 54 |
/** @phpstan-ignore instanceof.alwaysTrue */ |
| 55 |
return $unserialized instanceof UuidBuilderInterface; |
| 56 |
}); |
| 57 |
} |
| 58 |
} |
| 59 |
|