php__phplib/misc/boxed_scalars.php
Frederic G. MARAND cbc433477a Various minor commenting / indenting / reordering changes in the zoo.
- removed obsolete autoloader and get_temp_dir() functions
- indenting/bracing style mostly PSR1-style.
2012-05-06 12:01:49 +02:00

37 lines
686 B
PHP

<?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;
}
}