original_string: public function prepareForeignKeys()
      {
          $tables = $this->schemaManager->listTables();
  
          $fields = [];
  
          foreach ($tables as $table) {
              $primaryKey = $table->getPrimaryKey();
              if ($primaryKey) {
                  $primaryKey = $primaryKey->getColumns()[0];
              }
              $formattedForeignKeys = [];
              $tableForeignKeys = $table->getForeignKeys();
              foreach ($tableForeignKeys as $tableForeignKey) {
                  $generatorForeignKey = new GeneratorForeignKey();
                  $generatorForeignKey->name = $tableForeignKey->getName();
                  $generatorForeignKey->localField = $tableForeignKey->getLocalColumns()[0];
                  $generatorForeignKey->foreignField = $tableForeignKey->getForeignColumns()[0];
                  $generatorForeignKey->foreignTable = $tableForeignKey->getForeignTableName();
                  $generatorForeignKey->onUpdate = $tableForeignKey->onUpdate();
                  $generatorForeignKey->onDelete = $tableForeignKey->onDelete();
  
                  $formattedForeignKeys[] = $generatorForeignKey;
              }
  
              $generatorTable = new GeneratorTable();
              $generatorTable->primaryKey = $primaryKey;
              $generatorTable->foreignKeys = $formattedForeignKeys;
  
              $fields[$table->getName()] = $generatorTable;
          }
  
          return $fields;
      }
code: public function prepareForeignKeys()
      {
          $tables = $this->schemaManager->listTables();
  
          $fields = [];
  
          foreach ($tables as $table) {
              $primaryKey = $table->getPrimaryKey();
              if ($primaryKey) {
                  $primaryKey = $primaryKey->getColumns()[0];
              }
              $formattedForeignKeys = [];
              $tableForeignKeys = $table->getForeignKeys();
              foreach ($tableForeignKeys as $tableForeignKey) {
                  $generatorForeignKey = new GeneratorForeignKey();
                  $generatorForeignKey->name = $tableForeignKey->getName();
                  $generatorForeignKey->localField = $tableForeignKey->getLocalColumns()[0];
                  $generatorForeignKey->foreignField = $tableForeignKey->getForeignColumns()[0];
                  $generatorForeignKey->foreignTable = $tableForeignKey->getForeignTableName();
                  $generatorForeignKey->onUpdate = $tableForeignKey->onUpdate();
                  $generatorForeignKey->onDelete = $tableForeignKey->onDelete();
  
                  $formattedForeignKeys[] = $generatorForeignKey;
              }
  
              $generatorTable = new GeneratorTable();
              $generatorTable->primaryKey = $primaryKey;
              $generatorTable->foreignKeys = $formattedForeignKeys;
  
              $fields[$table->getName()] = $generatorTable;
          }
  
          return $fields;
      }
code_tokens: public function prepareForeignKeys ( ) { $ tables = $ this -> schemaManager -> listTables ( ) ; $ fields = [ ] ; foreach ( $ tables as $ table ) { $ primaryKey = $ table -> getPrimaryKey ( ) ; if ( $ primaryKey ) { $ primaryKey = $ primaryKey -> getColumns ( ) [ 0 ] ; } $ formattedForeignKeys = [ ] ; $ tableForeignKeys = $ table -> getForeignKeys ( ) ; foreach ( $ tableForeignKeys as $ tableForeignKey ) { $ generatorForeignKey = new GeneratorForeignKey ( ) ; $ generatorForeignKey -> name = $ tableForeignKey -> getName ( ) ; $ generatorForeignKey -> localField = $ tableForeignKey -> getLocalColumns ( ) [ 0 ] ; $ generatorForeignKey -> foreignField = $ tableForeignKey -> getForeignColumns ( ) [ 0 ] ; $ generatorForeignKey -> foreignTable = $ tableForeignKey -> getForeignTableName ( ) ; $ generatorForeignKey -> onUpdate = $ tableForeignKey -> onUpdate ( ) ; $ generatorForeignKey -> onDelete = $ tableForeignKey -> onDelete ( ) ; $ formattedForeignKeys [ ] = $ generatorForeignKey ; } $ generatorTable = new GeneratorTable ( ) ; $ generatorTable -> primaryKey = $ primaryKey ; $ generatorTable -> foreignKeys = $ formattedForeignKeys ; $ fields [ $ table -> getName ( ) ] = $ generatorTable ; } return $ fields ; }
docstring: Prepares foreign keys from table with required details.
  
  @return GeneratorTable[]
docstring_tokens: Prepares foreign keys from table with required details .