We should extract $entity here the same way for consistency. Then the condition below simplifies to `if ($entity)`.