Files
testcontainers-php/src/Utils/PortGenerator/FixedPortGenerator.php
T
Sergei Shitikov f05ea0020d - 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
- ...
2024-09-06 19:08:37 +02:00

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++];
}
}