You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PhpSingleton/tests/singleton.php

29 lines
623 B
PHP

<?php
/** @noinspection PhpIllegalPsrClassPathInspection */
require_once __DIR__ . '/../vendor/autoload.php';
use jrosset\Singleton\ISingleton;
use jrosset\Singleton\TSingleton;
class SingletonTest implements ISingleton {
use TSingleton;
private int $cpt;
private function __construct () {
$this->cpt = 0;
}
public function getCpt (): int {
return $this->cpt;
}
public function increment (): void {
$this->cpt++;
}
}
var_dump(SingletonTest::getInstance()->getCpt());
SingletonTest::getInstance()->increment();
var_dump(SingletonTest::getInstance()->getCpt());