Assign $document->getBrand() in a variable before the ternary op.