Please advise on this - selling just a short code

Can we sell just a code (php class with a function) that took too much research to implement to provide some operation on the strings? Do they accept that? I can offer it for 1 USD. It is unique and exclusive and not easy to implement. Thanks.