I have a attribute of a class that needs to be checked. The variable is a string but I want to convert it to an array if it is not empty, or else return an empty array.
'myVariable' => $token->getUser()->getRecord()->getLevel() ?: []
As of now, if getLevel() returns something, it returns as a string, but I want an array. Is there a way to do this while keeping the ?: operator.