public function validate($element): bool
    {
        if (!$expectedType = $this->getType()) {
            return true;
        }

        $expectedType = $this->typeMap[$expectedType] ?? $expectedType;
        $actualType   = \gettype($element);

        if (($actualType === 'object' && $element instanceof $expectedType) || $actualType === $expectedType) {
            return true;
        }

        throw new InvalidTypeException($expectedType, $actualType === 'object' ? \get_class($element) : $actualType);
    }