The original $title value is either string or false. So we're doing this only if it's false. $doc is an instance of Wikia\Search\Result, which implements ArrayAccess, and will return null if the key doesn't exist when offsetGet() is invoked.