periodo_v1 = new Periodo_v1(); $this->periodo_v2 = new Periodo_v2(); } public function get_v1(): array { return $this->periodo_v1->get(); } public function get_v2(): array { return $this->periodo_v2->get(); } public function get_merged(): array { $v2Data = $this->get_v2(); // Create an associative array with IdPeriodo as the key for faster lookup $v2Lookup = array_column($v2Data, null, 'IdPeriodo'); return array_map(function ($itemV1) use ($v2Lookup) { if (isset($v2Lookup[$itemV1['IdPeriodo']])) { $itemV2 = $v2Lookup[$itemV1['IdPeriodo']]; $mergedItem = array_merge($itemV1, $itemV2); unset($mergedItem['NombreCarrera']); // Remove NombreCarrera as specified return $mergedItem; } return $itemV1; // If no matching IdPeriodo found in v2, return the original v1 item }, $this->get_v1()); } } final class Espacios extends WebServiceSGU { public function __construct() { parent::__construct("/catalogos/espacios/seleccionar"); } } final class Carreras extends WebServiceSGU { public function __construct() { parent::__construct("/catalogos/carreras/seleccionar"); } } final class Horarios extends WebServiceSGU { public function __construct() { parent::__construct( "/seleccionar", <<