<?php
class Test
{
private File $file {
get => $this->file ??= new File($this->test1 . '-' . $this->test2 . '-' . random_int(0, PHP_INT_MAX));
}
public function __construct(
public string $test1,
public string $test2,
) {
}
public function doStuffA() {
var_dump($this->file->file . ' ~ A');
}
public function doStuffB() {
var_dump($this->file->file . ' ~ B');
}
}
class File {
public function __construct(
public string $file,
) {
}
}
$t = new Test('a', 'b');
$t->doStuffA();
$t->doStuffB();
$t->doStuffA();
$t->doStuffB();