123456789101112131415161718192021222324252627282930 |
- <?php
- /**
- * This class enables use of scalar values with classes implementing Comparable_Interface
- * $Id: boxed_scalars.php,v 1.2 2007-06-03 21:23:38 marand Exp $
- */
- 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;
- }
- }
|