mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-09-12 04:29:39 +00:00
- Move most of the stuff for backwards compatibility support into one class
- Added random port logic - Updated wait wtrategies - API alignments to make it similar to other official implementations - ...
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Testcontainers\Utils\PortGenerator;
|
||||
|
||||
class FixedPortGenerator implements PortGenerator
|
||||
{
|
||||
protected int $portIndex = 0;
|
||||
|
||||
public function __construct(
|
||||
/** @var int[] */
|
||||
protected array $ports
|
||||
) {
|
||||
}
|
||||
|
||||
public function generatePort(): int
|
||||
{
|
||||
if (!isset($this->ports[$this->portIndex])) {
|
||||
throw new \RuntimeException('No more ports available in the fixed list.');
|
||||
}
|
||||
|
||||
return $this->ports[$this->portIndex++];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user