<?php
class IntegerHandler {
public function add($n) {
return $this + $n;
}
public function multiplyBy($n) {
return $this * $n;
}
public function subtract($n) {
return $this - $n;
}
}
class ArrayHandler {
public function average() {
return array_sum($this) / count($this);
}
}
register_primitive_type_handler('int', 'IntegerHandler');
register_primitive_type_handler('array', 'ArrayHandler');
$number = 100;
$list = [1,2,3];
echo $number->add(4)->multiplyBy(10)->subtract($list->average()->add(2));
1