Check if the result of findAndModify() is not null before calling array_key_exists()