getCertificateFile
@param string $contents
3261
protected function getCertificateFile($contents)
    {
        $filename = storage_dir() . '/' . md5($contents) . '.pem';

        if (!file_exists($filename)) {
            file_put_contents($filename, $contents);
        }

        return realpath($filename);
    }
747374
public function save($contents)
    {
        $result = (string)file_put_contents($this->file, $contents, LOCK_EX | FILE_TEXT);
        $log = "[BEAR.Ace] saved:{$this->file} result:{$result}";

        return $log;
    }
51029
private function extractSignedContent($content)
    {
        $signature = substr($content, -40);

        if (substr($content, -43, 3) == self::VALUE_SEPARATOR . '_=' &&
            $signature == sha1(substr($content, 0, -40) . SettingsPiwik::getSalt())
        ) {
            // strip trailing: VALUE_SEPARATOR '_=' signature"
            return substr($content, 0, -43);
        }

        return false;
    }
875426
public function replaceContents($contents)
    {
        preg_match_all('/{{(.*)}}/', $contents, $matches);

        foreach ($matches[0] as $key => $match) {
            if (!empty($match)) {
                if (($resolved = $this->resolveVariable($matches[1][$key])) !== Constants::NOT_RESOLVED) {
                    $contents = str_replace($matches[0][$key], $resolved, $contents);
                }
            }
        }

        return $contents;
    }
619785
private function getTokenisedContent(string $content)
    {

        $tokens = token_get_all($content);


        $tokenised_content = array();
        $tokenised_content = $this->addToken($tokenised_content, $tokens, $content);

        return $tokenised_content;

    }
945285
protected static function compressFiles($content)
    {
        $var = ["\r\n", "\r", "\n", "\t", '  ', '    ', '    '];

        $content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content);

        $content = str_replace($var, '', $content);
        $content = str_replace('{ ', '{', $content);
        $content = str_replace(' }', '}', $content);
        $content = str_replace('; ', ';', $content);

        return $content;
    }
316281
public static function getContentMimeType($content)
    {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mimeType = finfo_buffer($finfo, $content);
        finfo_close($finfo);

        return $mimeType;
    }
1366507
protected function shouldUploadChunk($contents)
    {
        $size = is_string($contents) ? strlen($contents) : fstat($contents)['size'];

        return ($this->isPipe($contents) || ($size === null)) ? true : ($size > $this->maxChunkSize);
    }
617427
public function write(string $filename, string $contents): int
    {
        return (int)file_put_contents($filename, $contents);
    }
1049739
protected function preprocessWindowsPaths($contents)
    {
        $expression = "/'([A-Za-z]:)?((\\\\|\/)[^\\/:*?\"\'<>|\r\n]*)*'/";

        $paths = array();
        preg_match_all($expression, $contents, $paths);

        $modified = $contents;
        foreach ($paths[0] as $path) {
            $normalizedPath = str_replace('\\\\', '/', $path);
            $modified = str_replace($path, $normalizedPath, $modified);
        }

        if ($contents !== $modified) {
            $this->myCommand->info('Preprocessed windows paths in "bootstrap/cache/config.php".');
        }

        return $modified;
    }
228703
public function create($path, $contents='')
    {
        $this->fs[$path] = $this->newFile();
        $this->fs[$path]->setPath($path);
        return $this->fs[$path];
    }
1073971
protected function get_first_nonwhitespace( &$contents ) {
		while ( ( $line = array_shift( $contents ) ) !== null ) {
			$trimmed = trim( $line );
			if ( ! empty( $trimmed ) ) {
				break;
			}
		}

		return $line;
	}
385884
private function createTempFileWithContents(string $contents) : string
    {
        $filename = sprintf('%s.md', uniqid('KAC', true));
        $path = sprintf('%s/%s', sys_get_temp_dir(), $filename);
        file_put_contents($path, $contents);
        return $path;
    }
1149853
static public function getFileExt($content)
    {
        $types = array(
            255216 => 'jpg', 7173 => 'gif', 6677 => 'bmp', 13780 => 'png',
            7368   => 'mp3', 4838 => 'wma', 7784 => 'mid', 6063 => 'xml',
        );
        $typeInfo = @unpack("C2chars", substr($content, 0, 2));
        $typeCode = intval($typeInfo['chars1'] . $typeInfo['chars2']);
        return isset($types[$typeCode]) ? $types[$typeCode] : 'mp4';
    }
1042764
protected function getFileContent(Content $content)
    {
        $text = @file_get_contents($this->contentPath . $content->getPath());

        // @codeCoverageIgnoreStart
        if(null === $this->getContentPath())
        {
            throw new ConfigurationException('ContentPath is not set. Call setContentPath before reading a file content.');
        }
        // @codeCoverageIgnoreEnd

        if(false === $text)
        {
            throw new RenderException('Unable to read: ' . $content->getPath() . '. Full path: ' . ($this->getContentPath() . $content->getPath()));
        }

        return $text;
    }
910846
public function store_destfile_from_string($content) {
        if ($record = $this->get_file_record()) {
            $fs = get_file_storage();
            $existing = $fs->get_file(
                $record['contextid'],
                $record['component'],
                $record['filearea'],
                $record['itemid'],
                $record['filepath'],
                $record['filename']
            );
            if ($existing) {
                $existing->delete();
            }
            $file = $fs->create_file_from_string($record, $content);

            $this->raw_set('destfileid', $file->get_id());
        }

        return $this;
    }
1196925
public function sign($content) {
        if (is_array($content)) {
            $this->ignoreKeys = ['sign'];
            $content = $this->getSignContent($content);
        }
        if ($this->getSignType() == self::MD5) {
            return md5($content.$this->key);
        }
        return $this->getRsa()->sign($content);
    }