You can do this in one line instead of 8 with much easier to follow logic.
`$totalSize = (-1 === (int) $row['min']) ? -1 : (float) $row['sum'];`
Also, don't cast to integer, because this will caused problems on 32-bit systems.