PHP Classes

File: example/example.php

Recommend this page to a friend!
  Classes of Fabian Schmengler   Typesafe Enum   example/example.php   Download  
File: example/example.php
Role: Example script
Content type: text/plain
Description: Simple example usage
Class: Typesafe Enum
Implement enumerated values as class functions
Author: By
Last change: priority
Date: 13 years ago
Size: 895 bytes
 

Contents

Class file image Download
<?php
/**
 * Simple example usage
 *
 * @package TypesafeEnum
 * @author Fabian Schmengler <fschmengler@sgh-it.eu>
 * @copyright &copy; 2010 SGH informationstechnologie UG
 * @license BSD
 * @link http://creativecommons.org/licenses/BSD/
 * @version 1.1
 */

require_once realpath(dirname(__FILE__) . '/../typesafeenum.lib.php');

Enum::define_once('Suit', 'CLUBS', 'DIAMONTS', 'HEARTS', 'SPADES');

echo
'<pre>';

echo
"\n<b>Suit::CLUBS():</b>\n";
var_dump(Suit::CLUBS());

echo
"\n<b>Suit::DIAMONTS():</b>\n";
var_dump(Suit::DIAMONTS());

echo
"\n<b>Enum::valuesOf('Suit'):</b>\n";
var_dump(Enum::valuesOf('Suit'));

echo
"\n<b>testSuit(Suit::SPADES()):</b>\n";
testSuit(Suit::SPADES());

echo
'</pre>';


function
testSuit(Suit $suit)
{
    echo
" \$suit to string: $suit\n";
    echo
" \$suit===Suit::SPADES(): ";
   
var_export($suit===Suit::SPADES());
}
?>