Best explanation is http://en.wikipedia.org/wiki/HMAC-based_One-time_Password_Algorithm.  Truncate is:

    a function that selects 4 bytes from the result of the HMAC in a defined manner

This implementation is just a php port of the truncate algorithm from the [oath reference implementation](http://www.ietf.org/rfc/rfc4226.txt)