@param string $type
@throws InvalidTypeException

@return Metric
186337
public function setType($type) {
        if (!$this->isValidType($type)) {
            throw new InvalidTypeException('Type must be one of Metric::TYPE_*');
        }
        $this->type = $type;

        return $this;
    }
69647
public function setRequiredType($type)
    {
        if (!in_array($type, array('file', 'directory'))) {
            throw new \InvalidArgumentException("Input type must be either 'file' or 'directory'.");
        }

        if ($type === 'directory') {
            $this->setAllowDirectory(true);
        } else {
            $this->setAllowDirectory(false);
        }

        $this->requiredType = $type;

        return $this;
    }
192023
public function addType($type)
    {
        if (!in_array($type, $this->validTypes())) {
            throw new InvalidArgumentException(
                sprintf('Invalid cache type: "%s"', $type)
            );
        }

        $this->types[$type] = true;
        return $this;
    }
1009926
public function setType($type)
    {
        if (strlen($type) == 0) {
            throw new \InvalidArgumentException(sprintf('MIME type should not be empty'));
        }

        if (!preg_match('@^[^/]+/[^/]+$@', $type)) {
            throw new \InvalidArgumentException(sprintf('Invalid MIME type: %s', $type));
        }

        $this->type = $type;

        return $this;
    }
302293
public function cacheInvalidate( $type = self::ALL )
    {
        switch( $type ) {
            case self::PERSISTED:
                $return = count( $this->instancesPersisted );
                $this->instancesPersisted = array();
                return $return;
            case self::UNPERSISTED:
                $return = count( $this->instancesUnpersisted );
                $this->instancesUnpersisted = array();
                return $return;
            case self::ALL:
                $return = count( $this->instancesPersisted ) + count( $this->instancesUnpersisted );
                $this->instancesPersisted = array();
                $this->instancesUnpersisted = array();
                return $return;
        }
        throw new \InvalidArgumentException("Bad source `{$source}` passed to " . __FUNCTION__);
    }
731423
public function getTypeValidator($type)
    {
        if (in_array($type, $this->allowedTypeValidators, true) == false) {
            throw new InvalidTypeValidatorException('The type "'.$type.'" is invalid');
        }

        if (isset($this->typeValidators[$type]) == false) {
            $className = 'Mooti\\Validator\\TypeValidator\\'.ucfirst($type).'Validator';
            $this->typeValidators[$type] = $this->createNew($className);
        }

        return $this->typeValidators[$type];
    }
263137
public function osmType(string $type): self
    {
        if (\in_array($type, $this->osmType, true)) {
            $this->query['osm_type'] = $type;

            return $this;
        }

        throw new InvalidParameterException('OSM Type is not supported');
    }
966847
public function setType(?string $type): void
    {
        if (!in_array($type, static::getTypes(), true)) {
            throw new \InvalidArgumentException('Wrong zone type supplied.');
        }

        $this->type = $type;
    }
132690
public static function getType($type)
    {
        if (!isset(self::$typesMap[$type])) {
            throw new \InvalidArgumentException(sprintf('Invalid type specified "%s".', $type));
        }
        if (!isset(self::$typeObjects[$type])) {
            $className                = self::$typesMap[$type];
            self::$typeObjects[$type] = new $className;
        }

        return self::$typeObjects[$type];
    }
93476
public static function get(string $type): Transform
    {
        $namespace = '\\ModelHistory\\Model\\Transform\\';
        $transformClass = $namespace . Inflector::camelize($type) . 'Transform';
        if (class_exists($transformClass)) {
            return new $transformClass();
        }
        throw new InvalidArgumentException('Transform ' . $transformClass . ' not found!');
    }
772159
public static function get(string $type): AbstractWriter
    {
        if (!\array_key_exists($type, static::$invokableClasses)) {
            throw new InvalidArgumentException('Unsupported config file type: '.$type);
        }

        return new static::$invokableClasses[$type];
    }
725810
public function setInheritanceType($type)
    {
        if ( ! $this->_isInheritanceType($type)) {
            throw MappingException::invalidInheritanceType($this->name, $type);
        }
        $this->inheritanceType = $type;
    }
1148381
public function setEncodingType($type)
    {
        switch ($type) {
            case self::RFC3986:
                $this->encoding = 'rawurlencode';
                break;
            case self::RFC1738:
                $this->encoding = 'urlencode';
                break;
            case false:
                $this->encoding = function ($v) { return $v; };
                break;
            default:
                throw new \InvalidArgumentException('Invalid URL encoding type');
        }
    }
998468
public function setType($type)
    {
        if (!in_array($type, $this->getAvailableTypes())) {
            throw new \InvalidArgumentException('Unknown dependency type "' . $type . '"');
        }
        $this->type = $type;
        return $this;
    }
1075408
public function setMimetype($type)
    {
        if ($type === null || $type === false) {
            $this->mimetype = null;

            return $this;
        }

        if (!is_string($type)) {
            throw new InvalidArgumentException(
                'Mimetype must be a string'
            );
        }

        $this->mimetype = $type;

        return $this;
    }
975238
public static function createType($type)
    {
        if (!isset(static::$typeClasses[$type])) {
            throw new InvalidArgumentException('The asset type "'.$type.'" does not exist, only "'.implode('", "', static::getTypes()).'" are accepted');
        }

        $class = static::$typeClasses[$type];

        return new $class();
    }
632852
public function setType($type)
    {
        /**
         * Thoses WordType::__MIN and WordType::__MAX values are
         * only used to check if given type is okay according to
         * what we have in WordType.
         *
         * @see src/Client/Api/Enum/WordType.php
         */
        if (!($type >= WordType::__MIN && $type <= WordType::__MAX)) {
            throw new InvalidWordTypeException();
        }
        $this->type = $type;

        return $this;
    }