Check if layers can collide

Is there a way to check if two given layers are currently set to collide or not in the physics settings. I have a vast array of layers set to ignore collisions with certain others and it would great if I could check in code.

So basically:

IF (objectA.layer can collide with objectB.layer)
DO THIS

You want Physics.GetIgnoreLayerCollision.

Two layers can collide if collisions between them are NOT ignored, which makes for a sort of confusing double negative:

if (!Physics.GetIgnoreLayerCollision(objectA.layer, objectB.layer)) {
    //do something
}