Getting the content of file.

@internal

@access public

@param  string $filePath

@return string
176073
public function getFileContent( string$filePath ):string
	{
		return isset($this->fileGetter) ? $this->fileGetter($filePath) : file_get_contents($filePath);
	}
1237465
protected function getContent(string $path): ?vfsStreamContent
    {
        if (null === self::$root) {
            return null;
        }

        if (self::$root->getName() === $path) {
            return self::$root;
        }

        if ($this->isInRoot($path) && self::$root->hasChild($path) === true) {
            return self::$root->getChild($path);
        }

        return null;
    }
505098
protected function getFilesStatus(string $filepath) : bool
    {
        $status     = false;
        $path       = explode('/', $filepath);

        if (empty($path[0])) {
            // Internal Path
            $site           = $path[1];
            $acceptables    = ['css', 'CSS'];
            $filename       = $path[count($path) - 1];

            // check if style file has correct extension
            $nameParts = explode('.', $filename);
            if (!in_array($nameParts[count($nameParts) - 1], $acceptables)) {
                return false;
            }

            // Getting the subfolder(s)
            $subfolders     = '';
            for ($i = 2; $i <= count($path) - 2; $i++) {
                $subfolders .= $path[$i] . '/';
            }

            $fullPath = $_SERVER['DOCUMENT_ROOT'] . '/../module/MelisSites/' . $site . '/public/' . $subfolders . $filename;
            if (is_file($fullPath) && file_exists($fullPath)) {
                return true;
            }

        } else {
            // External Path
            if (filter_var($filepath, FILTER_VALIDATE_URL)) {
                $header_response = get_headers($filepath, 1);
                if (strpos($header_response[0], "200") !== false) {
                    // File exists
                    return true;
                }
            }
        }

        return $status;
    }
728389
protected function getContent(string $filename): string
    {
        return \file_get_contents($this->getSafepath($this->rootDir . DIRECTORY_SEPARATOR . $filename));
    }
191557
public static function filePutContents($filePath, $content = null)
    {
        // https://stackoverflow.com/a/282140/405758
        if (!file_exists(dirname($filePath))) {
            mkdir(dirname($filePath), 0775, true);
        }
        return file_put_contents($filePath, $content);
    }
1355794
public function parse($filepath)
    {
        $metadata = array();

        $reflectedClass = $this->getReflection($filepath);
        $metadata['class'] = $reflectedClass->getName();

        $propertiesMetadata = $this->processPropertiesParsing($reflectedClass);
        $metadata = array_merge($metadata, $propertiesMetadata);

        return $metadata;
    }
1347264
protected function getReflection($filepath)
    {
        // Regexp instead of tokenizer because of the bad perf @link > https://gist.github.com/1886076
        if (!preg_match('#^namespace\s+(.+?);.*class\s+(\w+).+;$#sm', file_get_contents($filepath), $captured)) {
            throw new \RuntimeException('Unable to find namespace or class declaration');
        }

        $fqcn = $captured[1].'\\'.$captured[2];

        try {
            $reflectedClass = new \ReflectionClass($fqcn);
        } catch (\ReflectionException $exception) {
            $this->registerAutoload($fqcn, $filepath);
            $reflectedClass = new \ReflectionClass($fqcn);
        }

        return $reflectedClass;
    }
824144
public static function getClassName($filePath)
    {
        $className = preg_replace('/\.php$/i', '', $filePath);
        $className = preg_replace('/^(application|custom)(\/|\\\)/i', '', $className);
        $className = '\\'.static::toFormat($className, '\\');

        return $className;
    }
1100047
public static function firstLine($filepath)
    {
        if (file_exists($filepath)) {
            $cacheRes = fopen($filepath, 'rb');
            $firstLine = fgets($cacheRes);
            fclose($cacheRes);

            return $firstLine;
        }

        return null;
    }
66766
public function readFile($filePath = null, array $options = [])
    {
        $items = parse_ini_file(
            $filePath,
            (empty($options)
                ? true
                : $options[ 'sections' ])
        );

        $this->merge($items);

        return $items;
    }
497692
private function parseNamespace($filePath): string
    {
        preg_match('/namespace(.*);/', file_get_contents($filePath), $result);
        return isset($result[1]) ? $result[1] . "\\" : '';
    }
697582
protected function getFileFunctions($filePath)
    {
        $source = file_get_contents($filePath);
        $tokens = token_get_all($source);

        $functions = [];
        $nextStringIsFunc = false;
        foreach($tokens as $token) {
            switch($token[0]) {
                case T_FUNCTION:
                    $nextStringIsFunc = true;
                    break;

                case T_STRING:
                    if ($nextStringIsFunc) {
                        $nextStringIsFunc = false;
                        $functions[] = $token[1];
                    }
                    break;
            }
        }

        return $functions;
    }
1002137
private function getTranslationsInFile($filePath)
    {
        
	 	// File extension ?
        $extOk = in_array(\Jig\Utils\FsUtils::getFileExtension($filePath), $this->getFileTypes());

        if ($extOk){
            foreach ($this->getBannedFileType() as $bannedExt){
                $extOk &= substr_compare($filePath, $bannedExt, strlen($filePath)-strlen($bannedExt), strlen($bannedExt)) !== 0;
            }
        }

        if ($extOk) {
            
		 	// We read the file.
		 	$lines = file($filePath);
		 	foreach ($lines as $line) {
                $strings = $this->getTranslationPhrases( $line );
                //preg_match_all("/__(\(| )+['\"](.*?)['\"](\))?/u", $line, $string);
                
                //lookup for __('to translate') or __ 'to translate'
            //    preg_match_all("/__(\(| )+(('(.*?)')|(\"(.*?)\"))(\))?/u", $line, $string);
            
                foreach($strings as $s) {
                    $tu = new tao_helpers_translation_TranslationUnit();
                    $tu->setSource(tao_helpers_translation_POUtils::sanitize($s));
                    $tus = $this->getTranslationUnits();
                    $found = false;
                    
                    // We must add the string as a new TranslationUnit only
                    // if a similiar source does not exist.
                    foreach ($tus as $t) {
                        if ($tu->getSource() == $t->getSource()) {
                            $found = true;
                            break;
                        }
                    }
                    
                    if (!$found) {
                        $tus[] = $tu;
                        $this->setTranslationUnits($tus);
                    }
                }
		 	}
		}
        
    }
272835
public static function getMimeType($filePath)
    {
        /*
         * The file does not exist?
         * Nothing to do
         */
        if (!is_string($filePath) || !is_readable($filePath)) {
            return '';
        }

        // 1st possibility: the finfo class
        if (class_exists('finfo')) {
            $finfo = new \finfo();

            return $finfo->file($filePath, FILEINFO_MIME_TYPE);
        }

        // 2nd possibility: the mime_content_type function
        if (function_exists('mime_content_type')) {
            return mime_content_type($filePath);
        }

        // Oops, there is no possibility to read the mime type
        $template = 'Neither \'finfo\' class nor \'mime_content_type\' function exists. There is no way to read the'
            . ' mime type of file \'%s\'.';

        $message = sprintf($template, $filePath);

        throw new \RuntimeException($message);
    }
465003
protected function readFile(string $filePath): string
    {
        /**
         * read bin
         */
        $handle = fopen($filePath, 'rb');
        $stream = fread($handle, $this->maxByteCacheLen);
        fclose($handle);
        return $stream;
    }
364058
public static function loadJsonFromFile($filePath)
    {
        if (!file_exists($filePath)) {
            throw new \RuntimeException("File '{$filePath}' doesn't exist");
        }

        $content = json_decode(file_get_contents($filePath));

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new JsonDecodeException(sprintf(
                'Cannot decode JSON from file "%s" (error: %s)',
                $filePath,
                static::lastJsonErrorMessage()
            ));
        }

        return $content;
    }
1069100
public static function openFile($filepath)
    {
        $contents = null;

        if ($realPath = realpath($filepath)) {
            $handle = fopen($realPath, 'rb');
            $contents = fread($handle, filesize($realPath));
            fclose($handle);
        }

        return $contents;
    }