Exports synonyms to a download file.

@param string $fileFormat
@return string
354801
public function exportSynonymsAction($fileFormat = 'txt')
    {
        $coreAdmin = $this->selectedSolrCoreConnection->getAdminService();
        $synonyms = $coreAdmin->getSynonyms();
        return $this->exportFile(ManagedResourcesUtility::exportSynonymsToTxt($synonyms), 'synonyms', $fileFormat);
    }
493664
public static function file($path, $format = '')
	{
		if ($format === '')
		{
			$format = self::getExtension($path);
		}
		$text = file_get_contents($path);
		return self::output($text, $format);
	}
1168831
public function get($format = null)
    {
        if ( ! is_null($format) )
            $this->setFormat($format);

        ob_start();
        call_user_func($this->getFunctionName(), $this->getImage());

        return ob_get_clean();
    }
623018
public function getByFormat($format)
    {
        foreach ($this->getExporters() as $exporter) {
            if ($exporter->support($format)) {
                return $exporter;
            }
        }

        throw new \RuntimeException(sprintf('No exporter found for "%s" format.', $format));
    }
666313
private function stripFormatExtension($path, $format)
    {
        $extension = '.' . $format;
        if (substr($path, -strlen($extension)) === $extension) {
            $path = substr($path, 0, strlen($path) - strlen($extension));
        }

        return $path;
    }
1069066
public static function formatHumanFileSize($sizeInBytes)
    {
        $terms = [
            'fr' => ['G' => 'go', 'M' => 'mo', 'K' => 'ko', 'B' => 'octets'],
            'en' => ['G' => 'gb', 'M' => 'mb', 'K' => 'kb', 'B' => 'bytes']
        ];
        $lang = (self::isFrench()) ? $terms['fr'] : $terms['en'];
        $fileSize = $sizeInBytes;
        $unit = $lang['B'];
        if ($sizeInBytes >= 1073741824) {
            $fileSize = round($sizeInBytes / 1024 / 1024 / 1024, 1);
            $unit = $lang['G'];
        } elseif ($sizeInBytes >= 1048576) {
            $fileSize = round($sizeInBytes / 1024 / 1024, 1);
            $unit = $lang['M'];
        } elseif ($sizeInBytes >= 1024) {
            $fileSize = round($sizeInBytes / 1024, 1);
            $unit = $lang['K'];
        }
        return self::formatDecimal($fileSize, 0, 2) . ' ' . $unit;
    }
1311281
public function download($dest, $callback = null)
    {
        if ($this->isFolder()) {
            return $this->downloadFolder($dest, $callback);
        }

        return $this->downloadFile($dest, $callback);
    }
780186
protected function getGlobPattern($fileToRotate, $fileExtension = '')
    {

        // load the file information
        $dirname = pathinfo($fileToRotate, PATHINFO_DIRNAME);
        $filename = pathinfo($fileToRotate, PATHINFO_FILENAME);

        // create a glob expression to find all log files
        $glob = str_replace(
            array(LogrotateScanner::FILENAME_FORMAT_PLACEHOLDER, LogrotateScanner::SIZE_FORMAT_PLACEHOLDER),
            array($filename, '[0-9]'),
            $dirname . '/' . $this->getFilenameFormat()
        );

        // append the file extension if available
        if (empty($fileExtension) === false) {
            $glob .= '.' . $fileExtension;
        }

        // return the glob expression
        return $glob;
    }
1075115
public function translatedFormat(string $format): string
    {
        $replacements = static::getFormatsToIsoReplacements();
        $context = '';
        $isoFormat = '';
        $length = mb_strlen($format);

        for ($i = 0; $i < $length; $i++) {
            $char = mb_substr($format, $i, 1);

            if ($char === '\\') {
                $replacement = mb_substr($format, $i, 2);
                $isoFormat .= $replacement;
                $i++;

                continue;
            }

            if (!isset($replacements[$char])) {
                $replacement = preg_match('/^[A-Za-z]$/', $char) ? "\\$char" : $char;
                $isoFormat .= $replacement;
                $context .= $replacement;

                continue;
            }

            $replacement = $replacements[$char];

            if ($replacement === true) {
                static $contextReplacements = null;

                if ($contextReplacements === null) {
                    $contextReplacements = [
                        'm' => 'MM',
                        'd' => 'DD',
                        't' => 'D',
                        'j' => 'D',
                        'N' => 'e',
                        'w' => 'e',
                        'n' => 'M',
                        'o' => 'YYYY',
                        'Y' => 'YYYY',
                        'y' => 'YY',
                        'g' => 'h',
                        'G' => 'H',
                        'h' => 'hh',
                        'H' => 'HH',
                        'i' => 'mm',
                        's' => 'ss',
                    ];
                }

                $isoFormat .= '['.$this->rawFormat($char).']';
                $context .= $contextReplacements[$char] ?? ' ';

                continue;
            }

            if ($replacement instanceof Closure) {
                $replacement = '['.$replacement($this).']';
                $isoFormat .= $replacement;
                $context .= $replacement;

                continue;
            }

            $isoFormat .= $replacement;
            $context .= $replacement;
        }

        return $this->isoFormat($isoFormat, $context);
    }
266483
private function createFormat($audioFormat)
    {
        switch ($audioFormat) {
            case 'aac':
                $format = new Aac();
                break;

            case 'flac':
                $format = new Flac();
                break;

            case 'vorbis':
                $format = new Vorbis();
                break;

            case 'mp3':
            default:
                $format = new Mp3();
                break;
        }

        return $format;
    }
177096
public function getFormattedImage($format)
    {
        $formatName = $format instanceof FormatInterface
            ? $format->getName()
            : $format
        ;

        return $this->formattedImages
            ->filter(function (FormattedImageInterface $formattedImage) use ($formatName) {
                return ($format = $formattedImage->getFormat())
                    && $format->getName() == $formatName
                ;
            })
            ->first() ?: null // first() returns "false" if collection empty
        ;
    }
112429
public function getHeaders($filename, $format = self::FORMAT_GUZZLE) {

        $rawHeaders = $this->getFile($filename);

        preg_match_all('/(.+):\ (.+)/i', $rawHeaders, $matches);

        // Curl format
        if($format == self::FORMAT_CURL) return $matches[0];

        // Guzzle format
        $headers = array();

        foreach($matches[0] as $i => $matche) {
            $headers[$matches[1][$i]] = $matches[2][$i];
        }

        return $headers;
    }
762680
public function prepare($fileContent)
    {
        $replacings = [
            '{name}',
            '{namespace}',
            '{testNamespace}',
            '{table}',
            '{getters}',
            '{interfaceGetters}',
            '{fillable}',
            '{repository}',
            '{directory}',
            '{eloquentTest}',
            '{repositoryTest}',
            '{repositoryTestData}',
        ];

        $replacements = [
            $this->getProvidedName(),
            $this->getAppNamespace(),
            $this->getTestsNamespace(),
            $this->getTable(),
            $this->getSettersGetters($this->fields),
            $this->getSettersGetters($this->fields, true),
            $this->getFillable($this->fields),
            $this->getRepositoryPayloads($this->fields),
            $this->getDirectory(),
            $this->getEloquentTests($this->fields),
            $this->getRepositoryTests($this->fields),
            $this->getRepositoryDataTests($this->fields),
        ];

        return str_replace($replacings, $replacements, $fileContent);
    }
1354573
public function getSkrillAmount($stringFormat = false)
    {
        $amount = (double)$this->data['mb_amount'];

        if ($stringFormat) {
            $amount = number_format($amount, 2, '.', '');
        }

        return $amount;
    }
940857
public function getFormat($name, $filePath, $mode) {
        $formats = $this->getFormats();
        if (!isset($formats[$name])) {
            throw new Exception("Format `$name` is not registered");
        }
        if (!is_callable($formats[$name])) {
            throw new Exception("Cannot generate format `$name`");
        }
        $format = call_user_func($formats[$name], $filePath, $mode);
        if (!$format instanceof Format) {
            throw new Exception("Cannot generate format `$name`");
        }
        return $format;
    }
103946
public static function reformatData($data, $sourceFormat = null, $targetFormat = null)
    {
        if (is_null($data) || ($sourceFormat == $targetFormat)) {
            return $data;
        }

        switch ($sourceFormat) {
            case DataFormats::JSON:
                if (is_array($data)) {
                    $data = self::jsonEncode($data);
                }
                switch ($targetFormat) {
                    case DataFormats::XML:
                        return static::jsonToXml($data);

                    case DataFormats::CSV:
                        return static::jsonToCsv($data);

                    case DataFormats::PHP_ARRAY:
                        return static::jsonToArray($data);
                }
                break;

            case DataFormats::XML:
                switch ($targetFormat) {
                    case DataFormats::JSON:
                        return static::xmlToJson($data);

                    case DataFormats::CSV:
                        return static::xmlToCsv($data);

                    case DataFormats::PHP_ARRAY:
                        return static::xmlToArray($data);
                }
                break;

            case DataFormats::CSV:
                switch ($targetFormat) {
                    case DataFormats::JSON:
                        return static::csvToJson($data);

                    case DataFormats::XML:
                        return static::csvToXml($data);

                    case DataFormats::PHP_ARRAY:
                        return static::csvToArray($data);
                }
                break;

            case DataFormats::PHP_ARRAY:
                switch ($targetFormat) {
                    case DataFormats::JSON:
                        //  Symfony Response object automatically converts this.
                        return $data;
//                        return static::arrayToJson( $data );

                    case DataFormats::XML:
                        return static::arrayToXml($data);

                    case DataFormats::CSV:
                        return static::arrayToCsv($data);

                    case DataFormats::TEXT:
                        return json_encode($data);

                    case DataFormats::PHP_ARRAY:
                        return $data;
                }
                break;

            case DataFormats::PHP_OBJECT:
                switch ($targetFormat) {
                    case DataFormats::JSON:
                        //  Symfony Response object automatically converts this.
                        return $data;
//                        return static::arrayToJson( $data );

                    case DataFormats::XML:
                        return static::arrayToXml($data);

                    case DataFormats::CSV:
                        return static::arrayToCsv($data);

                    case DataFormats::TEXT:
                        return json_encode($data);

                    case DataFormats::PHP_ARRAY:
                        return $data;
                }
                break;

            case DataFormats::RAW:
            case DataFormats::TEXT:
                // treat as string for the most part
                switch ($targetFormat) {
                    case DataFormats::JSON:
                        return json_encode($data);

                    case DataFormats::XML:
                        $root = config('df.xml_response_root', 'dfapi');

                        return '<?xml version="1.0" ?>' . "<$root>$data</$root>";

                    case DataFormats::CSV:
                    case DataFormats::TEXT:
                        return $data;

                    case DataFormats::PHP_ARRAY:
                        return [$data];
                }
                break;
        }

        return false;
    }
40826
public function downloadAttachment($attachmentIndex)
    {
        $fileInformation = $this->GetAttachment($attachmentIndex);
        //build URI to download attachment
        $strURI = Product::$baseProductUri . '/pdf/' . $this->getFileName() . '/attachments/' . $attachmentIndex . '/download';
        //sign URI
        $signedURI = Utils::sign($strURI);
        $responseStream = Utils::processCommand($signedURI, 'GET', '', '');
        $v_output = Utils::validateOutput($responseStream);
        if ($v_output === '') {
            Utils::saveFile($responseStream, AsposeApp::$outPutLocation . $fileInformation->Name);
            return '';
        } else
            return $v_output;
    }