TheDragonCode/card-number ? reverse-engineered prompt

Reverse engineered prompt

Build me a small PHP library for generating and checking card style numbers with Luhn’s algorithm.

I want to be able to pass in a number as text or as an integer, and have it tell me if it’s valid or not, even if the input has spaces or other separators mixed in. It should also generate the correct check digit for a base number, and support different card types like Visa, MasterCard, American Express, loyalty style numbers, and custom validators I can define myself.

Please include a simple way to format the generated number for things like bank cards and loyalty cards, and make the main API feel easy to use from one class. Add tests for the common cases, including valid and invalid inputs, different card types, and custom validation rules. If you need to check current PHP or Composer docs while implementing, go ahead and look them up online.