Generate and return a filepath that matches given vars

@param  array  $vars
@return string
336917
protected function getCachedFilepath(array $vars)
	{
		if (!isset($this->cacheDir))
		{
			return null;
		}

		$filepath = $this->cacheDir . '/http.' . $this->getCacheKey($vars);
		if (extension_loaded('zlib'))
		{
			$filepath = 'compress.zlib://' . $filepath . '.gz';
		}

		return $filepath;
	}
235768
protected function preparePaths(string $folder, array $paths, string $fileNames = ''): string
    {
        foreach ($paths as $path) {
            if (dirname($path) != $folder) {
                return ''; // all source paths must be the same
            }
            if ($fileNames != '') {
                $fileNames .= ':';
            }
            $fileNames .= basename($path);
        }

        return $fileNames;
    }
767603
public function dump_vars($vars)
    {
        $this->last_selector = null;
        $args = array();
        foreach (func_get_args() as $index => $func) {
            if ($func instanceof PheryResponse || $func instanceof PheryFunction) {
                $args[$index] = array($this->typecast($func, true, true));
            } elseif (is_object($func)) {
                $args[$index] = array(get_object_vars($func));
            } else {
                $args[$index] = array($func);
            }
        }

        return $this->cmd(6, $args);
    }
692486
protected function generatePathRegex() {
		if( $this->pathRegex ) { return; }
		$variables = array();
		$this->pathRegex = preg_replace_callback(
			'#\{([^\}]+)\}#sm',
			function($matches) use(&$variables) {
// 				debug('$matches', $matches);
				$regex = $var = null;
				static::extractVariable(str_replace('\.', '.', $matches[1]), $var, $regex);
				$variables[] = $var;
				return '('.$regex.')';
			},
			str_replace('.', '\.', $this->path)
		);
		$this->pathVariables = $variables;
	}
201162
private function buildFilePath (array $directories, string $fileName) : string
    {
        $dir = !empty($directories)
            ? "/" . implode("/", $directories)
            : "";

        $file = "" !== $fileName
            ? "/{$fileName}"
            : "";

        return $dir . $file;
    }
881351
protected function getJSTemplateVars($vars)
    {
        if (is_array($vars)) {
            return $vars;
        }
        
        if ($this->hasMethod($vars)) {
            return $this->{$vars}();
        }
        
        return [];
    }
819071
protected function getFilePath(string $path): string
    {
        if (empty($path)) {
            $path = $this->fileName;
        }

        return $path;
    }
256971
protected function values($vars)
    {
        if (is_array($vars)) {
            return $vars;
        }
        $attributes = array();
        foreach (explode('|', $vars) as $value) {
            if (strpos($value, '=')) {
                list($key, $value) = explode('=', $value);
                $attributes[trim($key)] = trim($value);
            }
        }

        return $attributes;
    }
631609
protected function _formatTemplate($template, array $vars) {
        $needles = array_map(create_function('$k', 'return "{{".$k."}}";'),
            array_keys($vars));
        $replacements = array_values($vars);
        // do replacements, then delete unused template vars
        return preg_replace('~{{[^}]+}}~', '',
            str_replace($needles, $replacements, $template));
    }
981736
public static function getVariables($matches, &$vars = null)
    {
        if (!$matches) {
            return [];
        }

        if ($vars === null) {
            $vars = [];
        }

        foreach ($matches as $i => $var) {
            if (is_numeric($i)) {
                continue;
            }

            if (strpos((string) $var, '/') !== false) {
                $var = explode('/', (string) $var);
            }

            $vars[$i] = $var;
        }

        return $vars;
    }
214007
public function compile($vars = array())
    {
        $out = $this->render($vars);

        $outputFile = $this->getOutputFile();
        $destinationDir = dirname($outputFile);
        if (!is_dir($destinationDir)) {
            mkdir($destinationDir, 0777, true);
        }

        if (!is_dir($outputFile)) {
            file_put_contents($outputFile, $out);
        } else {
            throw new \RuntimeException(sprintf(
                'Output path "%s" is directory.', $outputFile));
        }

        return $out;
    }
751719
private function createJavaScriptPaths(array $javascripts)
    {
        $files = array();

        foreach ($javascripts as $file) {
            if (!$this->isExternalJavaScriptFile($file)) {

                if (false !== strpos($file, '?')) {
                    $file = strstr($file, '?', true);
                }

                $file = $this->getBasePath() . $file;
            }

            $files[] = $file;
        }

        return $files;
    }
1244435
protected function varToString($var)
    {
        if (is_object($var)) {
            return sprintf('Object(%s)', get_class($var));
        }

        if (is_array($var)) {
            $a = array();
            foreach ($var as $k => $v) {
                $a[] = sprintf('%s => %s', $k, $this->varToString($v));
            }

            return sprintf("Array(%s)", implode(', ', $a));
        }

        if (is_resource($var)) {
            return sprintf('Resource(%s)', get_resource_type($var));
        }

        if (null === $var) {
            return 'null';
        }

        if (false === $var) {
            return 'false';
        }

        if (true === $var) {
            return 'true';
        }

        return (string) "'$var'";
    }
1270531
public function inflectPackageVars($vars)
    {
        if ($vars['type'] === 'microweber-template') {
            return $this->inflectTemplateVars($vars);
        }
        if ($vars['type'] === 'microweber-templates') {
            return $this->inflectTemplatesVars($vars);
        }
        if ($vars['type'] === 'microweber-core') {
            return $this->inflectCoreVars($vars);
        }
        if ($vars['type'] === 'microweber-adapter') {
            return $this->inflectCoreVars($vars);
        }
        if ($vars['type'] === 'microweber-module') {
            return $this->inflectModuleVars($vars);
        }
        if ($vars['type'] === 'microweber-modules') {
            return $this->inflectModulesVars($vars);
        }
        if ($vars['type'] === 'microweber-skin') {
            return $this->inflectSkinVars($vars);
        }
        if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') {
            return $this->inflectElementVars($vars);
        }

        return $vars;
    }
305648
public function describeVars(array $vars, $sortByName = true)
    {
        $result = '';
        if ($sortByName) {
            ksort($vars, SORT_NATURAL);
        }
        foreach ($vars as $name => $value) {
            $result .= $this->describeVar($name, $value);
        }

        return $result;
    }
1035005
public function filePath($var = null)
    {
        if ($var !== null) {
            // Filename of the page.
            $this->name = basename($var);
            // Folder of the page.
            $this->folder = basename(dirname($var));
            // Path to the page.
            $this->path = dirname($var, 2);
        }

        return $this->path . '/' . $this->folder . '/' . ($this->name ?: '');
    }
281586
public function path($var = null)
    {
        if ($var !== null) {
            // Folder of the page.
            $this->folder = basename($var);
            // Path to the page.
            $this->path = dirname($var);
        }

        return $this->path ? $this->path . '/' . $this->folder : null;
    }