public static function throwIfNot($actualObject, string $expectedType, bool $allowNull = false): void
    {
        if (!is_a($expectedType, $expectedType, true)) {
            if (\gettype($actualObject) !== $expectedType) {
                if (null === $actualObject && $allowNull) {
                    return;
                }
                throw new self($expectedType, $actualObject);
            }
            return;
        }

        if (!$actualObject instanceof $expectedType) {
            if (null === $actualObject && $allowNull) {
                return;
            }
            throw new self($expectedType, $actualObject);
        }
    }