Lines 100.00% 3 / 3
Methods 100.00% 2 / 2
Classes 100.00% 1 / 1
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 wasCausedByStewart 100.00% 2 / 2 100.00% 1 / 1 4
13final readonly class StewartIdentity
14{
15    public function __construct(public ?string $haUserId) {}
16
17    public function wasCausedByStewart(StateChange|EntityState|HaEvent $subject): bool
18    {
19        $context = $subject instanceof StateChange ? $subject->findCausingContext() : $subject->context;
20
21        return $this->haUserId !== null && $this->haUserId !== '' && $context?->userId === $this->haUserId;
22    }
23}