key = $key; $this->startAddress = $startAddress; $this->size = $size; $this->endianness = $endianness; } public function getMemorySegment(string $key): ?MemorySegment { foreach ($this->memorySegments as $segment) { if ($segment->key === $key) { return $segment; } } return null; } public function totalSegmentSize(): int { return array_sum( array_map( fn (MemorySegment $segment): int => (int) $segment->size, $this->memorySegments ) ); } public function segmentStartAddress(): int { return min( array_map( fn (MemorySegment $segment): int => (int) $segment->startAddress, $this->memorySegments ) ); } public function segmentEndAddress(): int { return max( array_map( fn (MemorySegment $segment): int => (int) $segment->startAddress + $segment->size - 1, $this->memorySegments ) ); } }