The text is a metaphor comparing a book to a friend due to the value and companionship it can provide. It does not exploit different meanings of a word or similar-sounding words for humorous effect.
A book is a friend .