Apply the transform to each token. Filter out the null tokens.

@param TransformationInterface $transform The transformation to be applied
486450
public function applyTransformation(TransformationInterface $transform)
    {
        // array_values for re-indexing
        $this->tokens = array_values(
            array_filter(
                array_map(
                    array($transform, 'transform'),
                    $this->tokens
                ),
                function ($token) {
                    return $token!==null;
                }
            )
        );
    }
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;
    }
188808
public function set(HelperInterface $helper, $alias = null)
    {
        $this->helpers[$helper->getName()] = $helper;
        if (null !== $alias) {
            $this->helpers[$alias] = $helper;
        }

        $helper->setCharset($this->charset);
    }
1277843
private function transform($object)
    {
        $class = trim(get_class($object), '\\');
        $transformer = array_key_exists($class, $this->transformers)
            ? $this->transformers[$class]
            : false;
        if (! $transformer) {
            return $this->convert($object);
        }

        return is_callable(($cb = $this->transformer($transformer)))
            ? $this->forceArray(call_user_func($cb, $object))
            : $this->convert($object);
    }
353354
private function getArtifactPath(Transformation $transformation)
    {
        return $transformation->getArtifact()
            ? $transformation->getTransformer()->getTarget() . DIRECTORY_SEPARATOR . $transformation->getArtifact()
            : null;
    }
734596
public function transform(ConstraintInterface $constraint)
    {
        $this->clear();
        $this->setConstraint($constraint);
        $constraint = $constraint->accept($this);
        $this->clear();

        return $constraint;
    }
733016
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof Language) {
            throw new TransformationFailedException('Expected a ' . Language::class . ' object.');
        }

        return $value->languageCode;
    }
794225
protected function transformKeysCase(array $transformed)
    {
        // Get the config for how many levels of keys to transform
        $levels = config('api.formatsOptions.transform_keys_levels', null);

        /**
         * Transform all keys to required case, to the specified number of levels (by default, infinite)
         */
        $transformed = $this->formatKeyCase($transformed, $levels);

        /*
         * However, if the level is 1, we also want to transform the first level of keys in a json field which has been cast to array
         */
        if ($levels == 1 && ! is_null($this->model)) {
            foreach ($this->model->getCasts() as $fieldName => $castType) {
                if ($castType == 'array') {
                    $fieldNameFormatted = $this->formatKeyCase($fieldName);
                    if (array_key_exists($fieldNameFormatted, $transformed)) {
                        $transformed[$fieldNameFormatted] = $this->formatKeyCase($transformed[$fieldNameFormatted]);
                    }
                }
            }
        }

        return $transformed;
    }
201473
public function transform(array &$samples) : void
    {
        if ($this->strategies === null) {
            throw new RuntimeException('Transformer has not been fitted.');
        }

        foreach ($samples as $row => &$sample) {
            foreach ($sample as $column => &$feature) {
                if ($feature === $this->placeholder) {
                    $strategy = $this->strategies[$column];

                    $feature = $strategy->guess();
                }
            }
        }
    }
923755
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof APIRoleAssignment) {
            throw new TransformationFailedException('Expected a ' . APIRoleAssignment::class . ' object.');
        }

        return $value->id;
    }
560216
public function applyFilter(ImageInterface $image, FilterInterface $filter)
    {
        if ($filter instanceof ImagineAware) {
            if ($this->imagine === null) {
                throw new InvalidArgumentException(sprintf('In order to use %s pass an Imagine\Image\ImagineInterface instance to Transformation constructor', get_class($filter)));
            }
            $filter->setImagine($this->imagine);
        }

        return $filter->apply($image);
    }
725070
private function normalizeTransforms($transforms): array
    {
        $r = [];

        foreach ($transforms as $t) {
            $r[] = $this->normalizeTransform((array)$t);
        }

        return $r;
    }
389738
public void transform(final File inputFile, final File outputFile, final List<XMLFilter> filters) throws DITAOTException {
        if (inputFile.equals(outputFile)) {
            transform(inputFile, filters);
        } else {
            transformFile(inputFile, outputFile, filters);
        }
    }
76245
protected static function injectTranslatorValue(TranslatorInterface $translator, TemplateInterface $template, $field): void
    {
        $setter = 'set'.ucfirst($field);
        $getter = 'get'.ucfirst($field);
        $refTpl = new \ReflectionClass($template);

        if ($refTpl->hasMethod($getter) && $refTpl->hasMethod($setter)) {
            $val = $template->{$getter}();

            if (null !== $val) {
                $template->{$setter}($translator->trans($val, [], $template->getTranslationDomain()));
            }
        }
    }
335989
public function transform($value)
    {
        if (null === $value) {
            return '';
        } elseif ($value instanceof Collection) {
            $values = $value->toArray();
        } elseif (is_array($value)) {
            $values = $value;
        } else {
            throw new TransformationFailedException('TagTransformer expects to transform an array or Collection value');
        }

        $propertyAccessor = $this->propertyAccessor;
        $property = $this->property;
        $values = array_map(function ($value) use ($propertyAccessor, $property) {
            return $propertyAccessor->getValue($value, $property);
        }, $values);

        return implode(',', $values);
    }
1202299
private function applyLetterbox(&$imageInstance, $transform)
    {
        if (isset($transform['width'], $transform['height'])) { // if both isn't set, there's no need for a letterbox
            /** @var ConfigModel $settings */
            $config = ImagerService::getConfig();

            $letterboxDef = $config->getSetting('letterbox', $transform);

            try {
                $size = new Box($transform['width'], $transform['height']);

                $position = new Point(
                    (int)floor(((int)$transform['width'] - $imageInstance->getSize()->getWidth()) / 2),
                    (int)floor(((int)$transform['height'] - $imageInstance->getSize()->getHeight()) / 2)
                );
            } catch (InvalidArgumentException $e) {
                Craft::error($e->getMessage(), __METHOD__);
                throw new ImagerException($e->getMessage(), $e->getCode(), $e);
            }

            $palette = new RGB();
            $color = $palette->color(
                $letterboxDef['color'] ?? '#000',
                isset($letterboxDef['opacity']) ? (int)($letterboxDef['opacity'] * 100) : 0
            );
            
            if ($this->imagineInstance !== null) {
                $backgroundImage = $this->imagineInstance->create($size, $color);
                $backgroundImage->paste($imageInstance, $position);
                $imageInstance = $backgroundImage;
            }
        }
    }
770722
public function transform(Value\ValueInterface $value)
    {
        return $this->placeholderUnwrap()->transform(parent::transform($value));
    }