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) |
---|---|---|---|
8.4.10 | 0.045 | 0.007 | 17.88 |
<?php
class NumberContainer
{
public int $sum {
get => $this->prop1 + $this->prop2 + $this->prop3;
}
public function __construct(
public int $prop1 {
set(int $value) {
if (isset($this->prop2) && isset($this->prop3) && $value + $this->prop2 + $this->prop3 !== 100) {
throw new \InvalidArgumentException("Setting prop1 to {$value} would make the sum be not equals 100.");
}
$this->prop1 = $value;
}
},
public int $prop2 {
set(int $value) {
if (isset($this->prop1) && isset($this->prop3) && $this->prop1 + $value + $this->prop3 !== 100) {
throw new \InvalidArgumentException("Setting prop2 to {$value} would make the sum be not equals 100.");
}
$this->prop2 = $value;
}
},
public int $prop3 {
set(int $value) {
if (isset($this->prop1) && isset($this->prop2) && $this->prop1 + $this->prop2 + $value !== 100) {
throw new \InvalidArgumentException("Setting prop3 to {$value} would make the sum be not equals 100.");
}
$this->prop3 = $value;
}
},
) {}
}
echo "Instanciate with 30, 50, 20" . PHP_EOL;
$container = new NumberContainer(30, 50, 20);
try {
echo "Setting prop2 to 666" . PHP_EOL;
$container->prop2 = 666;
} catch (InvalidArgumentException $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo "Setting prop3 to 12". PHP_EOL;
$container->prop2 = 12;
} catch (InvalidArgumentException $e) {
echo $e->getMessage() . PHP_EOL;
}
try {
echo "Instanciate with 1337, 42, 3886" . PHP_EOL;
$container = new NumberContainer(1337, 42, 3886);
} catch (InvalidArgumentException $e) {
echo $e->getMessage() . PHP_EOL;
}
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) |
---|---|---|---|
8.4.10 | 0.045 | 0.007 | 17.88 |