mirror of
https://github.com/stan220/testcontainers-php.git
synced 2026-09-08 17:29:29 +00:00
- Added random port logic - Updated wait wtrategies - API alignments to make it similar to other official implementations - ...
26 lines
527 B
PHP
26 lines
527 B
PHP
<?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++];
|
|
}
|
|
}
|