Adds an additional transform to the icon (only available with the JS SDK)

@param  string $transform
@return self
@throws \InvalidArgumentException
553419
public function addTransform($transform, $value)
    {
        if (is_string($transform) === false) {
            throw new \InvalidArgumentException(
                'Additional transforms must be non empty strings.'
            );
        }
        if (!array_key_exists($transform, $this->VALID_TRANSFORMS)) {
            throw new \InvalidArgumentException(
                'Invalid transform.'
            );
        }
        if($this->VALID_TRANSFORMS[$transform] == 'numeric' && !is_numeric($value))
        {
            throw new \InvalidArgumentException(
                'Transform '.$transform.' must have a numeric value.'
            );
        }
        if(is_array($this->VALID_TRANSFORMS[$transform]) && !in_array($value, $this->VALID_TRANSFORMS[$transform]))
        {
            throw new \InvalidArgumentException(
                'Transform '.$transform.' has an invalid value.'
            );
        }

        $this->transforms[] = array($transform, $value);

        return $this;
    }
430654
public function attribute($key, $value)
    {
        if (! in_array($key, $this->allowedAttributes)) {
            throw new InvalidArgumentException("Attribute [{$key}] does not exist.");
        }

        $this->attributes[Arr::get($this->aliases, $key, $key)] = $value;

        return $this;
    }
722801
protected function add($task) {
		if (is_string($task)) {
			$task = new $task($this->_config);
		}

		$class = get_class($task);
		if (!$task instanceof AbstractTask) {
			throw new InvalidArgumentException(
				"Cannot use '$class' as task, it is not implementing " . AbstractTask::class . '.'
			);
		}

		$this->tasks[$class] = $task;

		return $this;
	}
4026
private function getTransformedImage($sourceModel, $transform)
    {
        /** @var ConfigModel $settings */
        $config = ImagerService::getConfig();

        if ($config->getSetting('noop', $transform)) {
            // todo : just return source image unmodified
        }

        if ($this->imagineInstance === null) {
            $msg = Craft::t('imager', 'Imagine instance was not created for driver “{driver}”.', ['driver' => ImagerService::$imageDriver]);
            Craft::error($msg, __METHOD__);
            throw new ImagerException($msg);
        }

        // Create target model
        $targetModel = new LocalTargetImageModel($sourceModel, $transform);

        // Set save options
        $saveOptions = $this->getSaveOptions($targetModel->extension, $transform);

        // Do transform if transform doesn't exist, cache is disabled, or cache expired
        if (!$config->getSetting('cacheEnabled', $transform) ||
            !file_exists($targetModel->getFilePath()) ||
            (($config->getSetting('cacheDuration', $transform) !== false) && (FileHelper::lastModifiedTime($targetModel->getFilePath()) + $config->getSetting('cacheDuration', $transform) < time()))
        ) {
            // Make sure that we have a local copy.
            $sourceModel->getLocalCopy();

            // Check all the things that could go wrong(tm)
            if (!realpath($sourceModel->path)) {
                $msg = Craft::t('imager', 'Source folder “{sourcePath}” does not exist', ['sourcePath' => $sourceModel->path]);
                Craft::error($msg, __METHOD__);
                throw new ImagerException($msg);
            }

            if (!realpath($targetModel->path)) {
                try {
                    FileHelper::createDirectory($targetModel->path);
                } catch (Exception $e) {
                    // ignore for now, trying to create
                }

                if (!realpath($targetModel->path)) {
                    $msg = Craft::t('imager', 'Target folder “{targetPath}” does not exist and could not be created', ['targetPath' => $targetModel->path]);
                    Craft::error($msg, __METHOD__);
                    throw new ImagerException($msg);
                }

                $targetModel->path = realpath($targetModel->path);
            }

            try {
                $targetPathIsWriteable = FileHelper::isWritable($targetModel->path);
            } catch (ErrorException $e) {
                $targetPathIsWriteable = false;
            }

            if ($targetModel->path && !$targetPathIsWriteable) {
                $msg = Craft::t('imager', 'Target folder “{targetPath}” is not writeable', ['targetPath' => $targetModel->path]);
                Craft::error($msg, __METHOD__);
                throw new ImagerException($msg);
            }

            if (!file_exists($sourceModel->getFilePath())) {
                $msg = Craft::t('imager', 'Requested image “{fileName}” does not exist in path “{sourcePath}”', ['fileName' => $sourceModel->filename, 'sourcePath' => $sourceModel->path]);
                Craft::error($msg, __METHOD__);
                throw new ImagerException($msg);
            }

            if (!Craft::$app->images->checkMemoryForImage($sourceModel->getFilePath())) {
                $msg = Craft::t('imager', 'Not enough memory available to perform this image operation.');
                Craft::error($msg, __METHOD__);
                throw new ImagerException($msg);
            }

            // Create the imageInstance. only once if reuse is enabled, or always
            if ($this->imageInstance === null || !$config->getSetting('instanceReuseEnabled', $transform)) {
                $this->imageInstance = $this->imagineInstance->open($sourceModel->getFilePath());
            }

            $animated = false;

            // Check if this is an animated gif and we're using Imagick
            if ($sourceModel->extension === 'gif' && ImagerService::$imageDriver !== 'gd' && $this->imageInstance->layers()) {
                $animated = true;
            }

            // Run tranforms, either on each layer of an animated gif, or on the whole image.
            if ($animated) {
                if ($this->imageInstance->layers()) {
                    $this->imageInstance->layers()->coalesce();
                }

                // We need to create a new image instance with the target size, or letterboxing will be wrong.
                $originalSize = $this->imageInstance->getSize();
                $resizeSize = ImagerHelpers::getResizeSize($originalSize, $transform, $config->getSetting('allowUpscale', $transform));
                $layers = $this->imageInstance->layers() ?? [];
                $gif = $this->imagineInstance->create($resizeSize);

                if ($gif->layers()) {
                    $gif->layers()->remove(0);
                }

                list($startFrame, $endFrame, $interval) = $this->getFramesVars($layers, $transform);

                for ($i = $startFrame; $i <= $endFrame; $i += $interval) {
                    if (isset($layers[$i])) {
                        $layer = $layers[$i];
                        $this->transformLayer($layer, $transform, $sourceModel->extension);
                        $gif->layers()->add($layer);
                    }
                }

                $this->imageInstance = $gif;
            } else {
                $this->transformLayer($this->imageInstance, $transform, $sourceModel->extension);
            }

            // If Image Driver is imagick and removeMetadata is true, remove meta data
            if (ImagerService::$imageDriver === 'imagick' && $config->getSetting('removeMetadata', $transform)) {
                $this->imageInstance->strip();
            }

            // Convert the image to RGB before converting to webp/saving
            if ($config->getSetting('convertToRGB', $transform)) {
                $this->imageInstance->usePalette(new RGB());
            }

            // Save the transform
            if ($targetModel->extension === 'webp') {
                if (ImagerService::hasSupportForWebP()) {
                    $this->saveAsWebp($this->imageInstance, $targetModel->getFilePath(), $sourceModel->extension, $saveOptions);
                } else {
                    $msg = Craft::t('imager', 'This version of {imageDriver} does not support the webp format. You should use “craft.imager.serverSupportsWebp” in your templates to test for it.', ['imageDriver' => ImagerService::$imageDriver === 'gd' ? 'GD' : 'Imagick']);
                    Craft::error($msg, __METHOD__);
                    throw new ImagerException($msg);
                }
            } else {
                $this->imageInstance->save($targetModel->getFilePath(), $saveOptions);
            }

            $targetModel->isNew = true;
        }

        // create CraftTransformedImageModel for transformed image
        $imageModel = new CraftTransformedImageModel($targetModel, $sourceModel, $transform);

        return $imageModel;
    }
49894
public function set($key, $value)
    {
        if (! $value instanceof AdapterInterface) {
            throw new InvalidArgumentException(
                'Adding an object that does not implement AdapterInterface '.
                'to AdaptersMap.'
            );
        }
        return parent::set($key, $value);
    }
895483
public function with($attribute, $value)
    {
        $this->snakeable && $attribute = Str::snake($attribute);

        if (!$this->validate($attribute, $value)) {
            throw new InvalidArgumentException("Invalid attribute '{$attribute}'.");
        }

        $this->set($attribute, $value);

        return $this;
    }
1148896
private function assertTransform($transform): void
	{
		if (!is_string($transform)) {
			throw new \InvalidArgumentException(sprintf('Transform must be of the type string, %s given', gettype($transform)));
		}

		if ($transform === '') {
			throw new \InvalidArgumentException('Transform must not be empty');
		}
	}
144273
public function setTransformer($transformer)
    {
        if ($transformer !== null) {
            if (!$this->isValidTransformer($transformer)) {
                throw new InvalidTransformerException('Transformer must be a callable or implement TransformerInterface');
            }
        }

        $this->transformer = $transformer;

        return $this;
    }
776065
public function alias($alias)
    {
        $alias = (string)$alias;
        if (in_array($alias, $this->with)) {
            throw new \InvalidArgumentException("Cannot use alias '{$alias}' because a relation already uses it");
        }

        $this->alias = $alias;

        return $this;
    }
183679
public function transform()
	{
		if( !( $this->xml && $this->xsl ) )
			throw new InvalidArgumentException( 'XML and XSL must be set.' );
		$xml	= DOMDocument::loadXML( $this->xml );
		$xsl	= DOMDocument::loadXML( $this->xsl );
		$proc	= new XSLTProcessor();
		$proc->importStyleSheet( $xsl );
		$result =  $proc->transformToXML( $xml );
		return $result;
	}
727708
public function transform($object)
    {
        if (null === $object) {
            return;
        }

        if (!(is_array($object) || $object instanceof \Traversable)) {
            throw new \InvalidArgumentException(sprintf(
                'Traversable element expected, %s given',
                is_object($object) ? get_class($object) : gettype($object)
            ));
        }

        $result = [];
        foreach ($object as $key => $item) {
            $result[$key] = $this->transformer->transform($item);
        }

        return $result;
    }
213228
public function add($constant)
    {
        if (!$constant instanceof ConstantInterface) {
            throw new \InvalidArgumentException(
                'This Constant must be a instance of \ClassGeneration\ConstantInterface'
            );
        }

        if ($constant->getName() === null) {
            $constant->setName('constant' . ($this->count() + 1));
        }

        return parent::add($constant);
    }
298902
public function add($field, DataSetTransformerInterface $transformer)
    {
        if ($this->has($field)) {
            throw new TransformerInvalidColumnException($field);
        }

        $this->items[$field] = $transformer;
    }
644232
public function add($value)
    {
        if (! $value instanceof SpecificationInterface) {
            throw new InvalidArgumentException(sprintf(
                '"%s" does not implement "%s"!',
                (is_object($value)) ? get_class($value) : $value,
                SpecificationInterface::class
            ));
        }

        return parent::add($value);
    }
601844
public function add($elem): void
    {
        if (!$elem instanceof StubInterface) {
            throw new InvalidArgumentException(
                sprintf(
                    'Element must be an instance of "%s", "%s" given',
                    StubInterface::class,
                    \gettype($elem)
                )
            );
        }

        parent::add($elem);
    }
777093
public function add($value)
    {
        if (! $value instanceof ModifierInterface) {
            throw new InvalidArgumentException(sprintf(
                '"%s" does not implement "%s"!',
                (is_object($value)) ? get_class($value) : $value,
                ModifierInterface::class
            ));
        }

        return parent::add($value);
    }
379322
public function addPlaceholder($placeholder)
    {
        if (!isset(class_implements($placeholder)[PlaceholderInterface::class])) {
            throw new InvalidArgumentException('The class ['.$placeholder.'] should be a member of the ['.PlaceholderInterface::class.']');
        } elseif (in_array($placeholder, $this->placeholders)) {
            throw new InvalidArgumentException('The placeholder ['.$placeholder.'] is already added to the minifier!');
        }

        $this->placeholders[] = $placeholder;

        return $this->placeholders;
    }