diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33de594..b361d2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,11 +16,11 @@ jobs: fail-fast: false matrix: operating-system: [ubuntu-latest] - php-versions: ['7.3', '7.4', '8.0'] + php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2'] steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php @@ -28,22 +28,23 @@ jobs: php-version: ${{ matrix.php-versions }} coverage: pcov tools: composer:v2 - extensions: php-imagick + extensions: imagick env: - COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Get composer cache directory - id: composercache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT - name: Setup problem matchers run: | echo "::add-matcher::${{ runner.tool_cache }}/php.json" echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Cache composer dependencies - uses: actions/cache@v2 + uses: actions/cache@v3 with: - path: ${{ steps.composercache.outputs.dir }} + path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- diff --git a/README.md b/README.md index 513a55b..6372a93 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # CC Icons This is a PHP class that generates an image based on a -list of supported credit card types. It makes it easy to -get an image showing all supported payment types for a -payment processor. +list of supported credit card or cryptocurrency types. +It makes it easy to get an image showing all supported +payment types for a payment processor. ## Installation @@ -42,16 +42,26 @@ to the image that was created. By default, each image is ## List of Supported Icons Icons should be specified as a single word, case-insensitive -- AMEX -- Dankort -- DinersClub -- Discover -- JCB -- Maestro -- Aliases: `Switch`, `Solo` -- Mastercard -- Alias: `MC` -- PostePay -- UnionPay -- Visa -- Aliases: `Delta`, `UKE` +- Credit Cards: + - `AMEX` + - `Dankort` + - `DinersClub` + - `Discover` + - `JCB` + - `Maestro` -- Aliases: `Switch`, `Solo` + - `Mastercard` -- Alias: `MC` + - `PostePay` + - `UnionPay` + - `Visa` -- Aliases: `Delta`, `UKE` +- Cryptocurrencies: + - `BTC` (Bitcoin) + - `LTC` (Litecoin) + - `BCH` (Bitcoin Cash) + - `BNB` (Binance Coin) + - `ETH` (Ethereum) + - `USDT` (Tether) + - `USDC` (USD Coin) + ## Default Layouts diff --git a/src/CCImageMaker.php b/src/CCImageMaker.php index 27a9de0..6d1c5c3 100644 --- a/src/CCImageMaker.php +++ b/src/CCImageMaker.php @@ -22,7 +22,7 @@ class CCImageMaker /** @var array */ private $layout; - /* Give every CC icon a constant to reference */ + /* Give every CC icon an ID to reference */ const AMEX = 1; const DANKORT = 2; const DINERSCLUB = 3; @@ -34,8 +34,18 @@ class CCImageMaker const UNIONPAY = 9; const VISA = 10; + /* Give every cryptocurrency icon an ID to reference */ + const BTC = 1001; + const LTC = 1002; + const BCH = 1003; + const BNB = 1004; + const ETH = 1005; + const USDT = 1006; + const USDC = 1007; + /** Link supported CC string representations to constants */ protected static $cc_strings = [ + // Credit Cards "VISA" => self::VISA, "MASTERCARD" => self::MASTERCARD, "MC" => self::MASTERCARD, @@ -50,11 +60,21 @@ class CCImageMaker "AMEX" => self::AMEX, "JCB" => self::JCB, "UNIONPAY" => self::UNIONPAY, - "POSTEPAY" => self::POSTEPAY // Italian Post Office + "POSTEPAY" => self::POSTEPAY, // Italian Post Office + + // Cryptocurrencies + "BTC" => self::BTC, + "LTC" => self::LTC, + "BCH" => self::BCH, + "BNB" => self::BNB, + "ETH" => self::ETH, + "USDT" => self::USDT, + "USDC" => self::USDC, ]; - /** Link credit cards to their file name in src/icons/ */ + /** Link IDs to their file name in src/icons/ */ protected static $supported_cc_types = [ + // Credit Cards self::AMEX => "amex", self::DANKORT => "dankort", self::DINERSCLUB => "dinersclub", @@ -64,7 +84,16 @@ class CCImageMaker self::MASTERCARD => "mastercard", self::POSTEPAY => "postepay", self::UNIONPAY => "unionpay", - self::VISA => "visa" + self::VISA => "visa", + + // Cryptocurrencies + self::BTC => "btc", + self::LTC => "ltc", + self::BCH => "bch", + self::BNB => "bnb", + self::ETH => "eth", + self::USDT => "usdt", + self::USDC => "usdc", ]; /** Width/height of the icon files in src/icons, must be divisible by 4 */ diff --git a/src/icons/bch.png b/src/icons/bch.png new file mode 100644 index 0000000..588df18 Binary files /dev/null and b/src/icons/bch.png differ diff --git a/src/icons/bnb.png b/src/icons/bnb.png new file mode 100644 index 0000000..775e640 Binary files /dev/null and b/src/icons/bnb.png differ diff --git a/src/icons/btc.png b/src/icons/btc.png new file mode 100644 index 0000000..643cd34 Binary files /dev/null and b/src/icons/btc.png differ diff --git a/src/icons/eth.png b/src/icons/eth.png new file mode 100644 index 0000000..d70b50a Binary files /dev/null and b/src/icons/eth.png differ diff --git a/src/icons/ltc.png b/src/icons/ltc.png new file mode 100644 index 0000000..21b2c35 Binary files /dev/null and b/src/icons/ltc.png differ diff --git a/src/icons/usdc.png b/src/icons/usdc.png new file mode 100644 index 0000000..0ffc2c1 Binary files /dev/null and b/src/icons/usdc.png differ diff --git a/src/icons/usdt.png b/src/icons/usdt.png new file mode 100644 index 0000000..1255baa Binary files /dev/null and b/src/icons/usdt.png differ diff --git a/tests/CCImageMakerTest.php b/tests/CCImageMakerTest.php index 1e1e4e3..9995c63 100644 --- a/tests/CCImageMakerTest.php +++ b/tests/CCImageMakerTest.php @@ -72,7 +72,11 @@ public function makeImageProvider() [400, 200], 10, [3 => [3]] - ] + ], + 'Cryptocurrencies LTC and BCH' => [ + 'cryptocurrencies.png', + [CCImageMaker::LTC, CCImageMaker::BCH], + ], ]; } diff --git a/tests/images/cryptocurrencies.png b/tests/images/cryptocurrencies.png new file mode 100644 index 0000000..c048f6d Binary files /dev/null and b/tests/images/cryptocurrencies.png differ diff --git a/tests/regenerate-fixtures.php b/tests/regenerate-fixtures.php index 61cc5c7..86f00cd 100644 --- a/tests/regenerate-fixtures.php +++ b/tests/regenerate-fixtures.php @@ -2,7 +2,7 @@ use Vectorface\CCIcons\CCImageMaker; -require 'vendor/autoload.php'; +require __DIR__ . '/../vendor/autoload.php'; $regular_images = [ '1-icon' => ['AMEX'], @@ -11,7 +11,8 @@ '4-icon' => ['UNIONPAY', 'DISCOVER', 'MAESTRO', 'AMEX'], '5-icon' => ['VISA', 'DINERSCLUB', 'AMEX', 'DISCOVER', 'UNIONPAY'], '6-icon' => ['MASTERCARD', 'JCB', 'MAESTRO', 'UNIONPAY', 'AMEX', 'DISCOVER'], - 'empty' => [] + 'empty' => [], + 'cryptocurrencies' => ['LTC', 'BCH'], ]; $special_images = [ @@ -38,7 +39,7 @@ 'size' => [400, 200], 'padding' => 10, 'layout' => [3] - ] + ], ]; foreach ($regular_images as $filename => $types) {