← All changes
|
includes/sdk/google/ramsey/uuid/src/Provider/Node/FallbackNodeProvider.php
+10
-16
1.2.2
→
1.4.1
View file →
| @@ -9,34 +9,28 @@ | ||
| 9 | 9 | * @copyright Copyright (c) Ben Ramsey <ben@benramsey.com> |
| 10 | 10 | * @license http://opensource.org/licenses/MIT MIT |
| 11 | 11 | */ |
| 12 | 12 | declare (strict_types=1); |
| 13 | -namespace Dudlewebs\WPMCS\Ramsey\Uuid\Provider\Node; | |
| 13 | +namespace Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Provider\Node; | |
| 14 | 14 | |
| 15 | -use Dudlewebs\WPMCS\Ramsey\Uuid\Exception\NodeException; | |
| 16 | -use Dudlewebs\WPMCS\Ramsey\Uuid\Provider\NodeProviderInterface; | |
| 17 | -use Dudlewebs\WPMCS\Ramsey\Uuid\Type\Hexadecimal; | |
| 15 | +use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Exception\NodeException; | |
| 16 | +use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Provider\NodeProviderInterface; | |
| 17 | +use Dudlewebs\WPMCS\GCP\Ramsey\Uuid\Type\Hexadecimal; | |
| 18 | 18 | /** |
| 19 | - * FallbackNodeProvider retrieves the system node ID by stepping through a list | |
| 20 | - * of providers until a node ID can be obtained | |
| 19 | + * FallbackNodeProvider retrieves the system node ID by stepping through a list of providers until a node ID can be obtained | |
| 21 | 20 | */ |
| 22 | 21 | class FallbackNodeProvider implements NodeProviderInterface |
| 23 | 22 | { |
| 24 | 23 | /** |
| 25 | - * @var NodeProviderCollection | |
| 24 | + * @param iterable<NodeProviderInterface> $providers Array of node providers | |
| 26 | 25 | */ |
| 27 | - private $nodeProviders; | |
| 28 | - /** | |
| 29 | - * @param NodeProviderCollection $providers Array of node providers | |
| 30 | - */ | |
| 31 | - public function __construct(NodeProviderCollection $providers) | |
| 26 | + public function __construct(private iterable $providers) | |
| 32 | 27 | { |
| 33 | - $this->nodeProviders = $providers; | |
| 34 | 28 | } |
| 35 | - public function getNode(): Hexadecimal | |
| 29 | + public function getNode() : Hexadecimal | |
| 36 | 30 | { |
| 37 | 31 | $lastProviderException = null; |
| 38 | - foreach ($this->nodeProviders as $provider) { | |
| 32 | + foreach ($this->providers as $provider) { | |
| 39 | 33 | try { |
| 40 | 34 | return $provider->getNode(); |
| 41 | 35 | } catch (NodeException $exception) { |
| 42 | 36 | $lastProviderException = $exception; |
| @@ -42,7 +36,7 @@ | ||
| 42 | 36 | $lastProviderException = $exception; |
| 43 | 37 | continue; |
| 44 | 38 | } |
| 45 | 39 | } |
| 46 | - throw new NodeException('Unable to find a suitable node provider', 0, $lastProviderException); | |
| 40 | + throw new NodeException(message: 'Unable to find a suitable node provider', previous: $lastProviderException); | |
| 47 | 41 | } |
| 48 | 42 | } |