| @@ 472-499 (lines=28) @@ | ||
| 469 | ||
| 470 | $fkMethodName = null; |
|
| 471 | $rkMethodName = null; |
|
| 472 | if ($condition) { |
|
| 473 | if (array_key_exists(get_class($foo), static::$methodPrimary)) { |
|
| 474 | $line = static::$methodPrimary[get_class($foo)]; |
|
| 475 | $fkMethodName = $line['fk']; |
|
| 476 | $rkMethodName = $line['rk']; |
|
| 477 | } else { |
|
| 478 | $methodList = get_class_methods(get_class($foo)); |
|
| 479 | $fkMethodName = 'getQualifiedForeignPivotKeyName'; |
|
| 480 | foreach ($fkList as $option) { |
|
| 481 | if (in_array($option, $methodList)) { |
|
| 482 | $fkMethodName = $option; |
|
| 483 | break; |
|
| 484 | } |
|
| 485 | } |
|
| 486 | assert(in_array($fkMethodName, $methodList), 'Selected method, '.$fkMethodName.', not in method list'); |
|
| 487 | $rkMethodName = 'getQualifiedRelatedPivotKeyName'; |
|
| 488 | foreach ($rkList as $option) { |
|
| 489 | if (in_array($option, $methodList)) { |
|
| 490 | $rkMethodName = $option; |
|
| 491 | break; |
|
| 492 | } |
|
| 493 | } |
|
| 494 | assert(in_array($rkMethodName, $methodList), 'Selected method, '.$rkMethodName.', not in method list'); |
|
| 495 | $line = ['fk' => $fkMethodName, 'rk' => $rkMethodName]; |
|
| 496 | static::$methodPrimary[get_class($foo)] = $line; |
|
| 497 | } |
|
| 498 | } |
|
| 499 | return [$fkMethodName, $rkMethodName]; |
|
| 500 | } |
|
| 501 | ||
| 502 | private function polyglotKeyMethodBackupNames($foo, $condition = false) |
|
| @@ 509-535 (lines=27) @@ | ||
| 506 | ||
| 507 | $fkMethodName = null; |
|
| 508 | $rkMethodName = null; |
|
| 509 | if ($condition) { |
|
| 510 | if (array_key_exists(get_class($foo), static::$methodAlternate)) { |
|
| 511 | $line = static::$methodAlternate[get_class($foo)]; |
|
| 512 | $fkMethodName = $line['fk']; |
|
| 513 | $rkMethodName = $line['rk']; |
|
| 514 | } else { |
|
| 515 | $methodList = get_class_methods(get_class($foo)); |
|
| 516 | $fkMethodName = 'getForeignKeyName'; |
|
| 517 | foreach ($fkList as $option) { |
|
| 518 | if (in_array($option, $methodList)) { |
|
| 519 | $fkMethodName = $option; |
|
| 520 | break; |
|
| 521 | } |
|
| 522 | } |
|
| 523 | assert(in_array($fkMethodName, $methodList), 'Selected method, '.$fkMethodName.', not in method list'); |
|
| 524 | $rkMethodName = 'getQualifiedParentKeyName'; |
|
| 525 | foreach ($rkList as $option) { |
|
| 526 | if (in_array($option, $methodList)) { |
|
| 527 | $rkMethodName = $option; |
|
| 528 | break; |
|
| 529 | } |
|
| 530 | } |
|
| 531 | assert(in_array($rkMethodName, $methodList), 'Selected method, '.$rkMethodName.', not in method list'); |
|
| 532 | $line = ['fk' => $fkMethodName, 'rk' => $rkMethodName]; |
|
| 533 | static::$methodAlternate[get_class($foo)] = $line; |
|
| 534 | } |
|
| 535 | } |
|
| 536 | return [$fkMethodName, $rkMethodName]; |
|
| 537 | } |
|
| 538 | ||