<?php
/**
 *
 * Boxed scalar values, usable with classes implementing Comparable_Interface
 * based on an OSInet Finite_State_Machine (fsm).
 *
 * This version relies on OSInet FSM >= 1.6
 *
 * @copyright  (c) 2007 OSI
 * @license    Licensed under the CeCILL 2.0
 * @version    CVS: $Id: boxed_scalars.php,v 1.3 2007-06-10 19:39:54 marand Exp $
 * @link       http://wiki.audean.com/fsm/fsm
 * @since      Not applicable yet
 * @package    default
 */


/**
 * This class enables use of scalar values with classes implementing Comparable_Interface
 * @package default
 */
class boxed_int implements Comparable_Interface
  {
  protected $value;

  function __construct($n)
    {
    $this->value = $n;
    }

  function cmp(Comparable_Interface $other)
    {
    if ($this->value < $other->value)
      return -1;
    elseif ($this->value > $other->value)
      return 1;
    else
      return 0;
    }

  function as_int()
    {
    return $this->value;
    }
  }