PHPackages                             garak/card - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. garak/card

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

garak/card
==========

A PHP library to manage generic card games

v0.10.0(1mo ago)03202LGPL-3.0-or-laterPHPPHP ^8.2CI passing

Since Jun 16Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/garak/card)[ Packagist](https://packagist.org/packages/garak/card)[ RSS](/packages/garak-card/feed)WikiDiscussions main Synced today

READMEChangelog (9)Dependencies (5)Versions (13)Used By (2)

PHP Card library
================

[](#php-card-library)

[![Latest Stable Version](https://camo.githubusercontent.com/9e01961e4f04ddb34b555e028f3150a5a10cb083c0e70cf7a2c8077e47926d5d/687474703a2f2f706f7365722e707567782e6f72672f676172616b2f636172642f76)](https://packagist.org/packages/garak/card)[![Latest Unstable Version](https://camo.githubusercontent.com/ca6a43db4b01b157179d85137de6c3bd946ce4e8c08a07b8c1be40479be609c4/687474703a2f2f706f7365722e707567782e6f72672f676172616b2f636172642f762f756e737461626c65)](https://packagist.org/packages/garak/card)[![License](https://camo.githubusercontent.com/6eda0c0a45044f2e14b895963aeecb75aee83b6f9f2b429a3b6db968ef855dee/687474703a2f2f706f7365722e707567782e6f72672f676172616b2f636172642f6c6963656e7365)](https://packagist.org/packages/garak/card)[![PHP Version Require](https://camo.githubusercontent.com/744ef0ea312f650a1355135d358cc9acfc274861fd7428304b7eed060106f68a/687474703a2f2f706f7365722e707567782e6f72672f676172616b2f636172642f726571756972652f706870)](https://packagist.org/packages/garak/card)[![Maintainability](https://camo.githubusercontent.com/5d79d53aa62dc02927f27c9f21026d8b1acadfd454894b8f6bde302def7c6526/68747470733a2f2f716c74792e73682f67682f676172616b2f70726f6a656374732f636172642f6d61696e7461696e6162696c6974792e737667)](https://qlty.sh/gh/garak/projects/card)[![Code Coverage](https://camo.githubusercontent.com/051df61479dc0b04b20f2e45d1cea0ea6203bb604cd4b373b8d0677a9315df1f/68747470733a2f2f716c74792e73682f67682f676172616b2f70726f6a656374732f636172642f636f7665726167652e737667)](https://qlty.sh/gh/garak/projects/card)

[![https://commons.wikimedia.org/wiki/Category:Playing_cards#/media/File:A_pile_of_playing_cards.jpg](https://user-images.githubusercontent.com/179866/114412093-10e4a700-9bad-11eb-80cf-46e007ff6bde.jpg)](https://user-images.githubusercontent.com/179866/114412093-10e4a700-9bad-11eb-80cf-46e007ff6bde.jpg)

Introduction
------------

[](#introduction)

This library offers a few VO classes to use inside Card-related applications:

- `Card`: represents a Card, for example an ace of spades.
- `Rank`: represents the rank value of a Card, for example "A" or "7" ("T" is used for 10, to keep the same length).
- `Suit`: represents the card suit, for example spades or diamonds.
- `CardBack`: represents the back color of a card, for example red or blue. This allows distinguishing between multiple decks in games played with more than one deck.

Some more classes, more elaborate, are available. They are abstract, and thus require a custom implementation to extend them:

- `Hand`: represents a set of Card objects, usually the ones assigned to a player
- `HandsTrick`: represents a trick of hands (think for example Poker, when players show their hands to declare a winner)
- `CardTrick`: represents a trick of cards (think for example the 4 cards of a Bridge turn)

Installation
------------

[](#installation)

Just use `composer require garak/card`.

Usage
-----

[](#usage)

Example:

```
