12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- /**
- *
- * Boxed scalar values, usable with classes implementing Comparable_Interface.
- *
- * @copyright (c) 2007 OSI
- * @license Licensed under the CeCILL 2.0
- */
- /**
- * 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;
- }
- }
|