Get/set parsed file contents.

@param mixed $var
@return string|array
@throws \RuntimeException
186414
public function content($var = null)
    {
        if ($var !== null) {
            $this->content = $this->check($var);

            // Update RAW, too.
            $this->raw = $this->encode($this->content);

        } elseif ($this->content === null) {
            // Decode RAW file.
            try {
                $this->content = $this->decode($this->raw());
            } catch (\Exception $e) {
                throw new \RuntimeException(sprintf('Failed to read %s: %s', $this->filename, $e->getMessage()), 500, $e);
            }
        }

        return $this->content;
    }
1318673
public function routable($var = null)
    {
        if ($var !== null) {
            $this->routable = (bool)$var;
        }

        return $this->routable && $this->published();
    }
1112238
public function frontmatter($var = null)
    {

        if ($var) {
            $this->frontmatter = (string)$var;

            // Update also file object.
            $file = $this->file();
            if ($file) {
                $file->frontmatter((string)$var);
            }

            // Force content re-processing.
            $this->id(time() . md5($this->filePath()));
        }
        if (!$this->frontmatter) {
            $this->header();
        }

        return $this->frontmatter;
    }
119285
public static function getFileContents(string $file) : string
    {
        if (!is_readable($file)) {
            throw new RuntimeException(sprintf(
                'File "%s" does not exist or is not readable',
                $file
            ));
        }

        $contents = file_get_contents($file);
        if ($contents === false) {
            throw new RuntimeException(sprintf(
                'Could not read from existing and readable file "%s"',
                $file
            ));
        }

        return $contents;
    }
59878
public static function parseFromFile($filename)
    {
        if (file_exists($filename) && is_readable($filename)) {
            return new self(file_get_contents($filename));
        } else {
            throw new \RuntimeException(sprintf("File %s is not readable, or doesn't exist.", $filename));
        }
    }
180883
public function getFile($fileName) {
        $files = $this->getFiles();
        $found = null;
        foreach ($files as $file) {
            if($file->getRelativePathname() === $fileName){
                if(!$file->isReadable()){
                    throw new RuntimeException(sprintf("The file '%s' could not be read.",$fileName));
                }
                $found = $file;
                break;
            }
        }
        return $found;
    }
116551
public function text($var)
	{
		global $txt;

		// This should be extended by somebody else...
		if (!$this->name || empty($var))
			return false;

		// Does nothing if the file is already loaded.
		loadLanguage($this->name);

		return !empty($txt[$this->name .'_'. $var]) ? $txt[$this->name .'_'. $var] : false;
	}
666722
public function markdown($var = null)
    {
        $content = $this->content();

        if ($var !== null) {
            $content['markdown'] = (string) $var;
            $this->content($content);
        }

        return $content['markdown'];
    }
268046
public static function files(string $variable, $default = null) {
		return isset(self::$_files[$variable])
			? self::$_files[$variable]
			: $default;
	}
377920
public function getContent() {

            if($this->isSeekable())
                $this->rewind();

            if (!$this->isReadable() || ($contents = stream_get_contents($this->stream)) === false) {
                throw new \RuntimeException('Could not get contents of not readable stream');
            }

            return $contents;

        }
814615
public function content($var = null)
    {
        try {
            // If nothing has been loaded, attempt to get pre-compiled version of the file first.
            if ($var === null && $this->raw === null && $this->content === null) {
                $key = md5($this->filename);
                $file = PhpFile::instance(CACHE_DIR . "compiled/files/{$key}{$this->extension}.php");

                $modified = $this->modified();

                if (!$modified) {
                    return $this->decode($this->raw());
                }

                $class = get_class($this);

                $cache = $file->exists() ? $file->content() : null;

                // Load real file if cache isn't up to date (or is invalid).
                if (
                    !isset($cache['@class'])
                    || $cache['@class'] !== $class
                    || $cache['modified'] !== $modified
                    || $cache['filename'] !== $this->filename
                ) {
                    // Attempt to lock the file for writing.
                    try {
                        $file->lock(false);
                    } catch (\Exception $e) {
                        // Another process has locked the file; we will check this in a bit.
                    }

                    // Decode RAW file into compiled array.
                    $data = (array)$this->decode($this->raw());
                    $cache = [
                        '@class' => $class,
                        'filename' => $this->filename,
                        'modified' => $modified,
                        'data' => $data
                    ];

                    // If compiled file wasn't already locked by another process, save it.
                    if ($file->locked() !== false) {
                        $file->save($cache);
                        $file->unlock();

                        // Compile cached file into bytecode cache
                        if (function_exists('opcache_invalidate')) {
                            // Silence error if function exists, but is restricted.
                            @opcache_invalidate($file->filename(), true);
                        }
                    }
                }
                $file->free();

                $this->content = $cache['data'];
            }

        } catch (\Exception $e) {
            throw new \RuntimeException(sprintf('Failed to read %s: %s', basename($this->filename), $e->getMessage()), 500, $e);
        }

        return parent::content($var);
    }
1067526
public function metadata($var = null)
    {
        if ($var !== null) {
            $this->metadata = (array)$var;
        }

        // if not metadata yet, process it.
        if (null === $this->metadata) {
            $header_tag_http_equivs = ['content-type', 'default-style', 'refresh', 'x-ua-compatible'];

            $this->metadata = [];

            $metadata = [];
            // Set the Generator tag
            $metadata['generator'] = 'GravCMS';

            // Get initial metadata for the page
            $metadata = array_merge($metadata, Grav::instance()['config']->get('site.metadata'));

            if (isset($this->header->metadata)) {
                // Merge any site.metadata settings in with page metadata
                $metadata = array_merge($metadata, $this->header->metadata);
            }

            // Build an array of meta objects..
            foreach ((array)$metadata as $key => $value) {
                // Lowercase the key
                $key = strtolower($key);
                // If this is a property type metadata: "og", "twitter", "facebook" etc
                // Backward compatibility for nested arrays in metas
                if (is_array($value)) {
                    foreach ($value as $property => $prop_value) {
                        $prop_key = $key . ':' . $property;
                        $this->metadata[$prop_key] = [
                            'name' => $prop_key,
                            'property' => $prop_key,
                            'content' => htmlspecialchars($prop_value, ENT_QUOTES, 'UTF-8')
                        ];
                    }
                } else {
                    // If it this is a standard meta data type
                    if ($value) {
                        if (\in_array($key, $header_tag_http_equivs, true)) {
                            $this->metadata[$key] = [
                                'http_equiv' => $key,
                                'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
                            ];
                        } elseif ($key === 'charset') {
                            $this->metadata[$key] = ['charset' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')];
                        } else {
                            // if it's a social metadata with separator, render as property
                            $separator = strpos($key, ':');
                            $hasSeparator = $separator && $separator < strlen($key) - 1;
                            $entry = [
                                'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
                            ];

                            if ($hasSeparator && !Utils::startsWith($key, 'twitter')) {
                                $entry['property'] = $key;
                            } else {
                                $entry['name'] = $key;
                            }

                            $this->metadata[$key] = $entry;
                        }
                    }
                }
            }
        }

        return $this->metadata;
    }
647562
protected static function var_dump_to_string($var) {
		if(is_string($var))
			return $var;

		ob_start();
		var_dump($var);
		if(ob_get_length() > 1024)
			$str = '['.(is_object($var) ? get_class($var):gettype($var)).' - too big to display]';
		else
			$str = ob_get_contents();
		ob_end_clean();
		return $str;
	}
824346
public function getProperty($var = null)
    {
        if (null === $var) {
            return $this->properties;
        }

        if (isset($this->properties[$var])) {
            return $this->properties[$var];
        }

        return;
    }
197951
public function setFileSet($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\CloudStorageOptions_FileSet::class);
        $this->file_set = $var;

        return $this;
    }
864431
public function readContent($filePath)
    {
        if (!$this->fileExists($filePath)) {
            throw new \RuntimeException("File '{$filePath}' doesn't exists.");
        }

        $content = \file_get_contents($filePath);

        if (false === $content) {
            throw new \RuntimeException("Unable to get contents of file '{$filePath}'.");
        }

        return $content;
    }
259001
public function setFileName($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\TruncatableString::class);
        $this->file_name = $var;

        return $this;
    }