More tests
All checks were successful
The build was successful.

This commit is contained in:
2018-08-10 08:51:38 +02:00
parent 3252f54615
commit 5d9ccf9c65
4 changed files with 47 additions and 0 deletions

34
tests/singleton_test.aer Normal file
View File

@@ -0,0 +1,34 @@
final class Test {
private $value;
private function __construct() {
}
/* This is singleton */
public function getInstance() {
static $instance;
if(!$instance) {
$instance = new Test();
}
return $instance;
}
public function get() {
return $this->value;
}
public function set($value = 0) {
$this->value = $value;
}
}
final class Main {
public function __construct() {
$testA = Test::getInstance();
$testA->set(5);
$testB = Test::getInstance();
var_dump($testB->get());
}
} /* class */
new Main();