@param $value
@param $to

@return bool
@throws TransformerException
551856
protected function fail($value, $to)
  {
    if (true)
    {
      throw new TransformerException(
        sprintf("Value of type %s can not be converted to %s by this method.", gettype($value), $to)
      );
    }

    return false;
  }
1152847
public function transform($value): string
    {
        if (method_exists($value, 'toJson')) {
            return $value->toJson();
        }

        if ($value instanceof JsonSerializable || $value instanceof StdClass) {
            return json_encode($value);
        }

        if (! method_exists($value, '__toString')) {
            throw Untransformable::cannotTransformObject($value);
        }

        return "'{$value}'";
    }
270195
public static function convert($value, $to, $from)
    {
        if ($from instanceof Measure === false || $to instanceof Measure === false) {
            throw new Exception('`from` or `to` parameter is not a Measure');
        }
        if ($from->type !== $to->type) {
            throw new Exception('Measures have different types');
        }
        if ($from->id == $to->id) {
            return $value;
        }
        $converterClass = isset(static::$converters[$to->type]) === true
            ? static::$converters[$to->type]
            : 'DevGroup\Measure\converters\DefaultMeasureTypeConverter';
        return $converterClass::convert($value, $to, $from);
    }
295147
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

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

        return $value->id;
    }
1146997
public function reverseTransform($value)
    {
        if (empty($value)) {
            return null;
        }

        if (!is_string($value)) {
            throw new TransformationFailedException(
                'Invalid data, expected value type is string'
            );
        }

        try {
            return $this->languageService->loadLanguage($value);
        } catch (NotFoundException $e) {
            throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e);
        }
    }
667658
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!$value instanceof VersionInfo) {
            throw new TransformationFailedException(
                'Value cannot be transformed because passed value is not an VersionInfo object'
            );
        }

        return ['content_info' => $value->getContentInfo(), 'version_no' => $value->versionNo];
    }
25134
protected function transformRecursive($value)
    {
        if (is_array($value) || $value instanceof \Traversable) {
            foreach ($value as &$subvalue) {
                $subvalue = $this->transformRecursive($subvalue);
            }
        } else {
            $value = $this->transformer->transform($value);
        }

        return $value;
    }
40918
public function reverseTransform($value): ?Value
    {
        if ($value === null) {
            return null;
        }

        if (!is_array($value)) {
            throw new TransformationFailedException(
                sprintf('Expected a array, got %s instead', gettype($value))
            );
        }

        return new Value($value['destinationContentId'], $value['alternativeText']);
    }
350008
public function reverseTransform($value)
    {
        if (!is_array($value)) {
            throw new TransformationFailedException('Expected an array.');
        }

        return empty($value) ? null : (string)array_pop($value);
    }
268560
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!\is_string($value) || !is_numeric($value)) {
            throw new TransformationFailedException('Expected a numeric string.');
        }

        return (float) $value;
    }
628007
public function reverseTransform($value)
    {
        if (null === $value) {
            return false;
        }

        if (!is_bool($value)) {
            throw new UnexpectedTypeException($value, 'Boolean');
        }

        return true === $value ? $this->trueValue : null;
    }
92238
public function offsetSet($offset, $value)
    {
        if (!$value instanceof Transformation) {
            throw new \InvalidArgumentException(
                '\phpDocumentor\Transformer\Template may only contain items of '
                . 'type \phpDocumentor\Transformer\Transformation'
            );
        }

        $this->transformations[$offset] = $value;
    }
208681
protected function addClassName($to = 'class', $value = null)
    {
        $classes = explode(' ', (string) $this->getAttribute($to));

        $value = array_merge($classes, is_string($value) ? explode(' ', $value) : $value);

        return $this->set($to, implode(' ', array_unique($value)));
    }
174450
public function removeOne($value): bool
    {
        if ($this->isValidType($value) === false) {
            throw new MWrongTypeException("\$value", $this->getType(), $value);
        }

        $result = array_search($value, $this->list);

        if ($result === false) {
            throw new \OutOfBoundsException();
        }

        unset($this->list[$result]);

        return true;
    }
373326
public static function canCastToString($value)
    {
        if (is_scalar($value)) {
            return !is_bool($value) && !is_resource($value);
        } elseif (is_object($value)) {
            return method_exists($value, '__toString');
        }
        return false;
    }
556319
public function allEqualTo($value)
    {
        foreach ($this->getViewports() as $viewport) {
            
            if ($this->getField($viewport) != $value) {
                return false;
            }
            
        }
        
        return true;
    }
1126176
public function transform($value)
    {
        if ($value === null || $value == '') {
            return null;
        }
        if (!($value instanceof File)) {
            throw new TransformationFailedException('Expected an instance of a concrete5 file object.');
        }
        return intval($value->getFileID());
    }