I wanted to write the best implementation I could think of the following really, super simple and stupid OOP
model in php
.
class Number {
private $number = false;
function __construct($n) {
if(is_int($n)) {
$this->number = $n;
}
}
public function get() {
return $this->number;
}
}
class Numbers {
public static function multiply(Number $a, Number $b) {
return ($a->get() * $b->get());
}
}
////
// Example
////
$first = new Number(45);
$second = new Number(80);
echo Numbers::multiply($first, $second);
Anything you guys would change? I was thinking of having Numbers
extend Number
, but really, the type of operations (functions) Numbers does do not need to extend the Number class. Is there a better object oriented pattern for this model?