classForeignKeyEnds
final class ForeignKeyEnds
Answers which columns of the parent a foreign key points at.
A key may name them, or leave them out and mean the parent's primary key, so the two spellings are resolved to one answer here rather than at every place that has to follow the key.
Methods§
public function __construct(private TableDefinitionRegistry $registry)Parameters
$registry | TableDefinitionRegistry | Answers what a table declares |
public function referencedColumns(ForeignKeyDefinition $foreignKey): list<string>Answers the parent columns a key points at.
Parameters
$foreignKey | ForeignKeyDefinition | Key to follow |
Returns
list<string> The columns, or nothing when the parent is unknownTest cases 3
Called from 4
- method-call ZtdQuery\Shadow\ForeignKeyCascade::of() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:72
- method-call ZtdQuery\Shadow\ForeignKeyCascade::applyAction() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:196
- method-call ZtdQuery\Shadow\ForeignKeyEnds::areBalanced() packages/ztd-query-core/src/Shadow/ForeignKeyEnds.php:59
- method-call ZtdQuery\Shadow\ForeignKeyIntegrity::assertHolds() packages/ztd-query-core/src/Shadow/ForeignKeyIntegrity.php:50
Calls 1
- method-call TableDefinitionRegistry::get() line 39
public function areBalanced(ForeignKeyDefinition $foreignKey): boolReports whether a key names as many parent columns as child columns.
A key that does not cannot be followed at all: there is no pairing to read the child values against.
Parameters
$foreignKey | ForeignKeyDefinition | Key to test |
Returns
bool True when the two ends have the same number of columnsTest cases 2
Called from 2
Calls 2
- function-call
countline 59 - method-call ForeignKeyEnds::referencedColumns() line 59
Private surface 1§
Implementation details, listed for orientation only.
private TableDefinitionRegistry $registryTest cases 26§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
ForeignKeyEndsTest::testAreBalancedIsFalseWhereTheEndsDisagreecallsForeignKeyEndsTest::testAreBalancedWhenBothEndsNameTheSameNumberOfColumnscallsForeignKeyEndsTest::testReferencedColumnsAnswersTheColumnsTheKeyNamescallsForeignKeyEndsTest::testReferencedColumnsFallsBackToTheParentsPrimaryKeycallsForeignKeyEndsTest::testReferencedColumnsIsEmptyWhereTheParentIsUnknowncalls
Other tests reaching this symbol 21
SessionTestcallsForeignKeyCascadeTest::testApplyActionCarriesTheNewValueWhereTheActionSaysToCascadecallsForeignKeyCascadeTest::testApplyActionRefusesTheStatementWhereTheActionForbidsItcallsForeignKeyCascadeTest::testApplyActionSetsTheKeyToNullWhereTheActionSaysTocallsForeignKeyCascadeTest::testCarryDeleteDropsEveryChildThatWasHoldingTheKeyWhereTheActionCascadescallsForeignKeyCascadeTest::testCarryDeleteReachesNothingWhereTheParentTableStillHoldsTheKeycallsForeignKeyCascadeTest::testCarryDeleteSetsTheKeyToNullWhereTheActionSaysToRatherThanDroppingTheRowcallsForeignKeyCascadeTest::testCarryUpdateReachesNothingWhereTheParentTableStillHoldsTheOldKeycallsForeignKeyCascadeTest::testCarryUpdateWritesTheNewKeyIntoEveryChildThatWasHoldingTheOldOnecallsForeignKeyCascadeTest::testOfCarriesTheNewKeyToTheChildrenOfAnUpdatedParentcallsForeignKeyCascadeTest::testOfDeletesTheChildrenOfADeletedParentWhereTheActionSaysToCascadecallsForeignKeyCascadeTest::testOfFollowsNothingThroughAKeyWhoseEndsDisagreecallsForeignKeyCascadeTest::testOfLeavesTheChildrenAloneWhileAnotherParentRowHoldsTheKeyUpcallsForeignKeyIntegrityTest::testAssertHoldsChecksNothingThroughAKeyWhoseEndsDisagreecallsForeignKeyIntegrityTest::testAssertHoldsLeavesAKeyWithANullInItAlonecallsForeignKeyIntegrityTest::testAssertHoldsLeavesARowThatDoesNotCarryTheKeyColumnsAlonecallsForeignKeyIntegrityTest::testAssertHoldsPassesAShadowInWhichEveryChildFindsItsParentcallsForeignKeyIntegrityTest::testAssertHoldsRefusesAShadowInWhichAChildReferencesNothingcallsReferentialIntegrityEnforcerTestcallsShadowApplicationTestcallsStatementSimulatorTestcalls
Relations§
Instantiated in 1
Method calls 5
- method-call ZtdQuery\Shadow\ForeignKeyCascade::of() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:67
- method-call ZtdQuery\Shadow\ForeignKeyCascade::of() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:72
- method-call ZtdQuery\Shadow\ForeignKeyCascade::applyAction() packages/ztd-query-core/src/Shadow/ForeignKeyCascade.php:196
- method-call ZtdQuery\Shadow\ForeignKeyIntegrity::assertHolds() packages/ztd-query-core/src/Shadow/ForeignKeyIntegrity.php:47
- method-call ZtdQuery\Shadow\ForeignKeyIntegrity::assertHolds() packages/ztd-query-core/src/Shadow/ForeignKeyIntegrity.php:50