code: public function isJunctionTable(Table $table, $ignoreReferencedTables = false)
      {
          $foreignKeys = $table->getForeignKeys();
          if (count($foreignKeys) !== 2) {
              return false;
          }
  
          $columns = $table->getColumns();
          if (count($columns) < 2 || count($columns) > 3) {
              return false;
          }
  
          if ($table->hasPrimaryKey()) {
              $pkColumns = $table->getPrimaryKeyColumns();
          } else {
              $pkColumns = [];
          }
  
          if (count($pkColumns) === 1 && count($columns) === 2) {
              return false;
          }
  
          if (count($pkColumns) !== 1 && count($columns) === 3) {
              return false;
          }
  
          $fkColumnNames = [];
          foreach ($foreignKeys as $foreignKey) {
              $fkColumns = $foreignKey->getColumns();
              if (count($fkColumns) !== 1) {
                  return false;
              }
              $fkColumnNames[$fkColumns[0]] = true;
          }
  
          if (count($columns) === 3) {
              // Let's check that the third column (the ID is NOT a foreign key)
              if (isset($fkColumnNames[$pkColumns[0]])) {
                  return false;
              }
  
              // Let's check that the primary key is autoincremented
              $pkColumn = $table->getColumn($pkColumns[0]);
              if (!$pkColumn->getAutoincrement() && strpos($pkColumn->getComment(), '@Autoincrement') === false) {
                  return false;
              }
          }
  
          if ($ignoreReferencedTables && $this->isTableReferenced($table)) {
              return false;
          }
  
          return true;
      }
docs: Returns true if $table is a junction table.
  I.e:.
  
  - it must have exactly 2 foreign keys
  - it must have only 2 columns (or 3 columns if the third one is an autoincremented primary key).
  
  If $ignoreReferencedTables is true, junctions table that are pointed to by a foreign key of another
  table are ignored.
  
  @param Table $table
  @param bool  $ignoreReferencedTables
  
  @return bool