Skip to content

Commit

Permalink
Use consts & fix wording
Browse files Browse the repository at this point in the history
  • Loading branch information
RMartinOscar committed Oct 29, 2024
1 parent 2cfa91a commit e573361
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/Services/Allocations/AssignmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public function handle(Node $node, array $data, ?Server $server = null): array
if (str_contains($port, '-')) {
[$start, $end] = explode('-', $port);
if (is_numeric($start) && is_numeric($end)) {
$start = max((int) $start, 1024);
$end = min((int) $end, 65535);
$start = max((int) $start, self::PORT_FLOOR);
$end = min((int) $end, self::PORT_CEIL);

return range($start, $end);
}
Expand All @@ -96,7 +96,7 @@ public function handle(Node $node, array $data, ?Server $server = null): array
})
->unique()
->sort()
->filter(fn ($port) => $port > 1024 && $port < 65535)
->filter(fn ($port) => $port > self::PORT_FLOOR && $port < self::PORT_CEIL)
->values();

$insertData = $ports->map(function (int $port) use ($node, $ip, $data, $server) {
Expand All @@ -123,7 +123,7 @@ public function handle(Node $node, array $data, ?Server $server = null): array
}

if ($failed->isNotEmpty()) {
throw new DisplayException("Could not add provided allocation IP address ({$data['allocation_ip']}) with Ports ({$failed->join(', ')}) already exist.");
throw new DisplayException("Could not add provided allocations, IP address ({$data['allocation_ip']}) with Ports ({$failed->join(', ')}) already exist.");
}

$this->connection->commit();
Expand Down

0 comments on commit e573361

Please sign in to comment.