Exports a coverage to a Istanbul compatible JSON format.

@param  array  $options The option array where the possible values are:
-`'collector'`      _object_ : The collector instance.
@return string
13948
public static function export($options)
    {
        $defaults = [
            'collector' => null,
            'base_path' => getcwd()
        ];
        $options += $defaults;

        $collector = $options['collector'];

        $export = [];

        $base = $options['base_path'] ? rtrim($options['base_path'], DS) . DS : '';

        foreach ($collector->export() as $file => $coverage) {
            $path = $base . $file;
            $export[$path] = static::_export($path, $collector->parse($file), $coverage);
        }

        return json_encode($export);
    }
565554
protected function optionsToRaw(array $options)
    {
        $collections = [];

        foreach ($options as $lang => $labels) {
            $finalWithTranslations = [];
            foreach ($labels as $label) {
                if ($label->isPlain) {
                    $collections[$label->value] = $label->text;
                } else {
                    $collections[$label->lang][$label->value] = $label->text;
                }
            }
        }

        $finals = [];

        foreach ($collections as $value => $collection) {
            $finals[$value] = is_array($collection) ? (object) $collection : $collection;
        }

        return (object) $finals;
    }
152559
public function toJson($key = null, $options = 0)
    {
        if (is_string($key)) {
            return json_encode($this->get($key), $options);
        }
        $options = $key === null ? 0 : $key;
        return json_encode($this->elements, $options);
    }
179687
public function encode(array $options = [])
    {
        $options = array_merge(
            [
                'inline'                        => 2,
                'indent'                        => 4,
                'exceptionOnInvalidType'        => false,
                'objectSupport'                 => false
            ],
            $options
        );

        return SymfonyYaml::dump(
            $this->getContents(),
            $options['inline'],
            $options['indent'],
            $options['exceptionOnInvalidType'],
            $options['objectSupport']
        );
    }
1362114
public function encode(array $options = [])
    {
        $options = array_replace(
            [
                'encodingOptions'       => $this->getOption('encodingOptions')
            ],
            $options
        );

        $json = json_encode($this->getContents(), $options['encodingOptions']);

        if ($json === false) {
            switch (json_last_error()) {
                case JSON_ERROR_DEPTH:
                    $msg = 'The maximum stack depth has been exceeded.';

                    break;
                case JSON_ERROR_STATE_MISMATCH:
                    $msg = 'Occurs with underflow or with the modes mismatch.';

                    break;
                case JSON_ERROR_CTRL_CHAR:
                    $msg = 'Control character error, possibly incorrectly encoded.';

                    break;
                case JSON_ERROR_UTF8:
                    $msg = 'alformed UTF-8 characters, possibly incorrectly encoded.';

                    break;
                default:
                    $msg = 'Unknown error';
            }

            throw EncodeException::create($this->getPath(), $msg);
        }

        return $json;
    }
990523
public function toJson($options = 0)
    {
        // Models' toJson() calls their toArray() function.  We don't want this to
        // happen twice
        if (!is_a($this, Model::class)) {
            $this->runSerializeTransforms();
        }

        // Continue execution
        return parent::toJson($options);
    }
1027637
public function toJson($options = 0)
	{
		$json = json_encode($this->jsonSerialize(), $options);

		if (JSON_ERROR_NONE !== json_last_error()) {
			throw JsonEncodingException::forObject($this, json_last_error_msg());
		}

		return $json;
	}
1257182
public function json(array $data = array(), $options = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
    {

        if (!headers_sent())
        {
            header('Cache-Control: no-cache, must-revalidate');
            header('Expires: Tue, 19 May 1981 18:00:00 GMT');
            header('Content-type: application/json; charset=utf-8');
        }

        /**
         * @var \Deimos\Helper\Helpers\Json $json
         */
        $json = clone $this->helper->json();
        $json->setOption((array)$options);

        return $json->encode($data);

    }
1288415
public function getAsHtml($options = [])
    {
        $defaults = [
            'table_id' => null,
            'table_class' => null,
            'translations' => [
                'title' => 'Card',
                'maskedPan' => 'Masked Pan',
                'token' => 'Token'
            ],
        ];

        $options = array_merge($defaults, $options);
        $translations = $options['translations'];

        $html = "<table id='{$options['table_id']}' class='{$options['table_class']}'>";
        $html .= "<tbody><tr><td>" . $translations['maskedPan'] . "</td><td>" . $this->maskedPan . "</td></tr>";
        $html .= "<tr><td>" . $translations['token'] . "</td><td>" . $this->token . "</td></tr></tbody>";
        $html .= "</table>";

        return $html;
    }
721339
public function toString($format='Json', array $options=[])
  {
    $handler = Format::getInstance($format);
    return $handler->objectToString($this->data, $options);
  }
195197
public function getData(array $options)
    {
        $provider = $this->getProvider();

        $ownerDetails = $provider->getResourceOwner($this->accessToken);

        $json = $ownerDetails->toArray();

        $data = [
            'externalId' => null,
            'name'       => null,
            'profileUrl' => null,
            'photoUrl'   => null,
            'birthday'   => null,
            'email'      => null,
            'gender'     => null,
            'location'   => null,
            'language'   => null
        ];
        if (isset($json['id']) && $json['id']) {
            $data['externalId'] = $json['id'];
            $data['photoUrl'] = sprintf($this->imageUrlTemplate, $json['id']);
        }
        if (isset($json['name']) && $json['name']) {
            $data['name'] = $json['name'];
        }
        if (isset($json['link']) && $json['link']) {
            $data['profileUrl'] = $json['link'];
        }
        if (isset($json['birthday']) && $json['birthday']) {
            $data['birthday'] = DateTime::createFromFormat('m/d/Y', $json['birthday']);
        }
        if (isset($json['email']) && $json['email']) {
            $data['email'] = $json['email'];
        }
        if (isset($json['gender']) && $json['gender']) {
            $data['gender'] = $json['gender'];
        }
        if (isset($json['location']['name']) && $json['location']['name']) {
            $data['location'] = $json['location']['name'];
        }
        if (isset($json['hometown']['name']) && $json['hometown']['name']) {
            $data['location'] = $json['hometown']['name'];
        }
        if (isset($json['locale']) && $json['locale']) {
            $data['language'] = Locale::getPrimaryLanguage($json['locale']);
        }
        return new Result($data);
    }
240749
public function objectToString($object, $options = array())
	{
		if (is_string($object))
		{
			return $object;
		}

		$format = 'object';
		if (isset($options['format']) && $options['format'])
		{
			$format = $options['format'];
		}

		// Build the object variables string
		$vars = '';
		foreach (get_object_vars($object) as $k => $v)
		{
			if (is_scalar($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = '" . addcslashes($v, '\\\'') . "';\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => '" . addcslashes($v, '\\\'') . "',\n";
					break;
				}
			}
			elseif (is_array($v) || is_object($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = " . $this->getArrayString((array) $v) . ";\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => " . $this->getArrayString((array) $v) . ",\n";
					break;
				}
			}
			elseif (is_null($v))
			{
				switch ($format)
				{
					case 'object':
						$vars .= "\tvar $" . $k . " = '';\n";
					break;
					case 'array':
						$vars .= "\t'" . $k . "' => '',\n";
					break;
				}
			}
		}

		$str  = "<?php\n";
		switch ($format)
		{
			case 'object':
				if (!isset($options['class']) || !$options['class'])
				{
					$options['class'] = 'Config';
				}
				$str .= "class " . $options['class'] . "\n";
				$str .= "{\n";
				$str .= $vars;
				$str .= "}";
			break;
			case 'array':
				$str .= "return array(\n";
				$str .= $vars;
				$str .= ");";
			break;
		}

		// Use the closing tag if it not set to false in parameters.
		if (isset($options['closingtag']) && $options['closingtag'])
		{
			$str .= "\n?>";
		}

		return $str;
	}
12051
public function toJson(int $options = 0)
    {
        $json = json_encode($this->toArray(), $options);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new JsonEncodeException(json_last_error_msg());
        }

        return $json;
    }
846513
protected function getUrl(array $options): string
    {
        $urlOptions = [];
        $this->setOriginAndDestinationOption($urlOptions, $options);
        $this->setViaOption($urlOptions, $options);
        $this->setDateOption($urlOptions, $options);

        $urlOptions = array_merge($urlOptions, $options);

        return sprintf('trip?%s&format=json', http_build_query($urlOptions));
    }
612112
private function getOption($option, array $options)
    {
        return isset($options[$option]) ? $options[$option] : $this->$option;
    }
1037265
protected function getCliDispatchScriptFileName(array $options = [])
    {
        $webDirectory = isset($options['webDirectory']) ? trim($options['webDirectory'], '\\/') : '';
        return $webDirectory !== '' ? sprintf('%s/typo3/cli_dispatch.phpsh', $webDirectory) : 'typo3/cli_dispatch.phpsh';
    }
1029293
protected function optionsToAjax($options)
    {
        $processed = [];
        foreach ($options as $id => $result) {
            $processed[] = ['id' => $id, 'name' => trans($result)];
        }
        return $processed;
    }