original_string: protected function mergeDataTables(DataTable\DataTableInterface $dataTable, DataTable\DataTableInterface $dataTable2)
      {
          if ($dataTable instanceof DataTable\Map) {
              $dataTables = $dataTable->getDataTables();
  
              foreach ($dataTables as $label => $table) {
  
                  $versionDataTables = $dataTable2->getDataTables();
  
                  if (!array_key_exists($label, $versionDataTables)) {
                      continue;
                  }
                  $newDataTable = $this->mergeDataTables($table, $versionDataTables[$label]);
                  $dataTable->addTable($newDataTable, $label);
              }
  
          } else if (!$dataTable->getRowsCount() && $dataTable2->getRowsCount()) {
              $dataTable2->filter('GroupBy', array('label', function ($label) {
                  if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $label, $matches)) {
                      return $matches[1]; // should match for browsers
                  }
                  if (strpos($label, ';')) {
                      return substr($label, 0, 3); // should match for os
                  }
                  return $label;
              }));
              return $dataTable2;
          }
  
          return $dataTable;
      }
code: protected function mergeDataTables(DataTable\DataTableInterface $dataTable, DataTable\DataTableInterface $dataTable2)
      {
          if ($dataTable instanceof DataTable\Map) {
              $dataTables = $dataTable->getDataTables();
  
              foreach ($dataTables as $label => $table) {
  
                  $versionDataTables = $dataTable2->getDataTables();
  
                  if (!array_key_exists($label, $versionDataTables)) {
                      continue;
                  }
                  $newDataTable = $this->mergeDataTables($table, $versionDataTables[$label]);
                  $dataTable->addTable($newDataTable, $label);
              }
  
          } else if (!$dataTable->getRowsCount() && $dataTable2->getRowsCount()) {
              $dataTable2->filter('GroupBy', array('label', function ($label) {
                  if (preg_match("/(.+) [0-9]+(?:\.[0-9]+)?$/", $label, $matches)) {
                      return $matches[1]; // should match for browsers
                  }
                  if (strpos($label, ';')) {
                      return substr($label, 0, 3); // should match for os
                  }
                  return $label;
              }));
              return $dataTable2;
          }
  
          return $dataTable;
      }
code_tokens: protected function mergeDataTables ( DataTable \ DataTableInterface $ dataTable , DataTable \ DataTableInterface $ dataTable2 ) { if ( $ dataTable instanceof DataTable \ Map ) { $ dataTables = $ dataTable -> getDataTables ( ) ; foreach ( $ dataTables as $ label => $ table ) { $ versionDataTables = $ dataTable2 -> getDataTables ( ) ; if ( ! array_key_exists ( $ label , $ versionDataTables ) ) { continue ; } $ newDataTable = $ this -> mergeDataTables ( $ table , $ versionDataTables [ $ label ] ) ; $ dataTable -> addTable ( $ newDataTable , $ label ) ; } } else if ( ! $ dataTable -> getRowsCount ( ) && $ dataTable2 -> getRowsCount ( ) ) { $ dataTable2 -> filter ( 'GroupBy' , array ( 'label' , function ( $ label ) { if ( preg_match ( "/(.+) [0-9]+(?:\.[0-9]+)?$/" , $ label , $ matches ) ) { return $ matches [ 1 ] ; // should match for browsers } if ( strpos ( $ label , ';' ) ) { return substr ( $ label , 0 , 3 ) ; // should match for os } return $ label ; } ) ) ; return $ dataTable2 ; } return $ dataTable ; }
docstring: That methods handles the fallback to version datatables to calculate those without versions.
  
  Unlike DevicesDetection plugin now, the UserSettings plugin did not store archives holding the os and browser data without
  their version number. The "version-less" reports were always generated out of the "version-containing" archives .
  For big archives (month/year) that ment that some of the data was truncated, due to the datatable entry limit.
  To avoid that data loss / inaccuracy in the future, DevicesDetection plugin will also store archives without the version.
  For data archived before DevicesDetection plugin was enabled, those archives do not exist, so we try to calculate
  them here from the "version-containing" reports if possible.
  
  @param DataTable\DataTableInterface $dataTable
  @param DataTable\DataTableInterface $dataTable2
  @return DataTable\DataTableInterface
docstring_tokens: That methods handles the fallback to version datatables to calculate those without versions .