| 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 <ben@benramsey.com> |
| 10 |
* @license http://opensource.org/licenses/MIT MIT |
| 11 |
*/ |
| 12 |
declare (strict_types=1); |
| 13 |
namespace Dudlewebs\WPMCS\Ramsey\Uuid\Builder; |
| 14 |
|
| 15 |
use Dudlewebs\WPMCS\Ramsey\Collection\AbstractCollection; |
| 16 |
use Dudlewebs\WPMCS\Ramsey\Uuid\Converter\Number\GenericNumberConverter; |
| 17 |
use Dudlewebs\WPMCS\Ramsey\Uuid\Converter\Time\GenericTimeConverter; |
| 18 |
use Dudlewebs\WPMCS\Ramsey\Uuid\Converter\Time\PhpTimeConverter; |
| 19 |
use Dudlewebs\WPMCS\Ramsey\Uuid\Guid\GuidBuilder; |
| 20 |
use Dudlewebs\WPMCS\Ramsey\Uuid\Math\BrickMathCalculator; |
| 21 |
use Dudlewebs\WPMCS\Ramsey\Uuid\Nonstandard\UuidBuilder as NonstandardUuidBuilder; |
| 22 |
use Dudlewebs\WPMCS\Ramsey\Uuid\Rfc4122\UuidBuilder as Rfc4122UuidBuilder; |
| 23 |
use Traversable; |
| 24 |
/** |
| 25 |
* A collection of UuidBuilderInterface objects |
| 26 |
* |
| 27 |
* @extends AbstractCollection<UuidBuilderInterface> |
| 28 |
*/ |
| 29 |
class BuilderCollection extends AbstractCollection |
| 30 |
{ |
| 31 |
public function getType(): string |
| 32 |
{ |
| 33 |
return UuidBuilderInterface::class; |
| 34 |
} |
| 35 |
/** |
| 36 |
* @psalm-mutation-free |
| 37 |
* @psalm-suppress ImpureMethodCall |
| 38 |
* @psalm-suppress InvalidTemplateParam |
| 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 |
| 48 |
* a UuidInterface instance |
| 49 |
* |
| 50 |
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint |
| 51 |
* @psalm-suppress RedundantConditionGivenDocblockType |
| 52 |
*/ |
| 53 |
public function unserialize($serialized): void |
| 54 |
{ |
| 55 |
/** @var array<array-key, UuidBuilderInterface> $data */ |
| 56 |
$data = unserialize($serialized, ['allowed_classes' => [BrickMathCalculator::class, GenericNumberConverter::class, GenericTimeConverter::class, GuidBuilder::class, NonstandardUuidBuilder::class, PhpTimeConverter::class, Rfc4122UuidBuilder::class]]); |
| 57 |
$this->data = array_filter($data, function ($unserialized): bool { |
| 58 |
return $unserialized instanceof UuidBuilderInterface; |
| 59 |
}); |
| 60 |
} |
| 61 |
} |
| 62 |
|