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.7.0(11mo ago)01782LGPL-3.0-or-laterPHPPHP ^8.1CI passing

Since Jun 16Pushed 10mo ago1 watchersCompare

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

READMEChangelog (6)Dependencies (1)Versions (9)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/307e29e56d60a89c194951a299a8775eeb5217a65b91bb363383bfcd19b88118/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32386338633965653836303762393363343732372f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/garak/card/maintainability)[![Test Coverage](https://camo.githubusercontent.com/02fa5650ec154b340481a6cfb7ae6d5c76b4fb2f4271313e8c29caa643086059/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f32386338633965653836303762393363343732372f746573745f636f766572616765)](https://codeclimate.com/github/garak/card/test_coverage)

[![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.

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:

```
