@ 2015-12-16T11:54:09Z <?php
class PieceOfSheet
{
private $cells = [];
function add($name, $value)
{
$this->cells[$name] = $value;
}
function get($name)
{
return $this->cells[$name];
}
function all()
{
return $this->cells;
}
}
class Person
{
public $name;
public $age;
public $gender;
public $from;
function __construct($name, $age, $gender, $from)
{
$this->name = $name;
$this->age = $age;
$this->gender = $gender;
$this->from = $from;
}
}
class StuffDoer
{
private $sheet;
function __construct(PieceOfSheet $sheet)
{
$this->sheet = $sheet;
}
function doStuff()
{
$data = [
'prathna' => function (Person $person) {
return $person->name;
},
'chris' => function (Person $person) {
return $person->gender;
},
'adam' => function (Person $person) {
return $person->from;
},
'deepthi' => function (Person $person) {
return $this->age;
}
];
foreach (['adam', 'chris', 'prathna'] as $name) {
$this->addMoreSheet($this->sheet, $data[$name]);
}
return $this->sheet->all();
}
function addMoreSheet(PieceOfSheet $sheet, $cell, callable $getData, Person $person)
{
$sheet->add($cell, call_user_func_array($getData, [$person]);
}
}
$s = new StuffDoer(new PieceOfSheet());
var_dump($s->doStuff());
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.0.0 0.007 0.073 20.24 5.6.16 0.013 0.077 20.46 5.6.15 0.007 0.073 18.22 5.6.14 0.007 0.080 18.19 5.6.13 0.013 0.073 18.28 5.6.12 0.007 0.083 21.07 5.6.11 0.003 0.083 21.13 5.6.10 0.017 0.073 21.13 5.6.9 0.003 0.063 20.87 5.6.8 0.010 0.073 20.40 5.5.30 0.003 0.040 17.99 5.5.29 0.003 0.040 17.94 5.5.28 0.003 0.053 20.77 5.5.27 0.013 0.060 20.79 5.5.26 0.003 0.040 20.88 5.5.25 0.007 0.077 20.60 5.5.24 0.013 0.077 20.18
preferences:dark mode live preview
132.59 ms | 1398 KiB | 8 Q