chore: complete update
This commit is contained in:
27
src/Framework/DI/SingletonDetector.php
Normal file
27
src/Framework/DI/SingletonDetector.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Framework\DI;
|
||||
|
||||
use App\Framework\Attributes\Singleton;
|
||||
use App\Framework\Reflection\ReflectionProvider;
|
||||
|
||||
/**
|
||||
* Erkennt ob eine Klasse als Singleton markiert ist
|
||||
*/
|
||||
final readonly class SingletonDetector
|
||||
{
|
||||
public function __construct(
|
||||
private ReflectionProvider $reflectionProvider,
|
||||
private InstanceRegistry $instanceRegistry
|
||||
) {}
|
||||
|
||||
public function isSingleton(string $class): bool
|
||||
{
|
||||
if ($this->instanceRegistry->hasSingleton($class)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$reflection = $this->reflectionProvider->getClass($class);
|
||||
return count($reflection->getAttributes(Singleton::class)) > 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user