Read & parse CSV file.

@param string $fullPath
@return DItem[]
970414
private function readCsv($fullPath)
    {
        $result = [];
        $entries = $this->hlpCsv->read($fullPath);
        foreach ($entries as $one) {
            $i=0;
            $fromId = $one[$i++];
            $fromName = $one[$i++];
            $toId = $one[$i++];
            $toName = $one[$i++];
            $volume = $one[$i++];

            $item = new DItem();
            $item->from = $fromId;
            $item->to = $toId;
            $item->value = $volume;
            $result[] = $item;
        }
        return $result;
    }
520860
protected function getFilesFromFolder($folderPath)
    {
        return FileHelper::findFiles($folderPath, [
            'recursive' => false,
            'caseSensitive' => false,
            'only' => ['*.php'],
            'filter' => function ($path) {
                return in_array(substr(basename($path), 0, 1), $this->ignorePrefix) ? false : null;
            }]);
    }
57536
protected function parse($coverallsYmlPath)
    {
        $file = new Path();
        $path = realpath($coverallsYmlPath);

        if ($file->isRealFileReadable($path)) {
            $parser = new Parser();
            $yml = $parser->parse(file_get_contents($path));

            return empty($yml) ? [] : $yml;
        }

        return [];
    }
468514
protected function get_stripped_file_contents($fullpath) {

        $source = file_get_contents($fullpath);
        $tokens = token_get_all($source);
        $output = '';
        $doprocess = false;
        foreach ($tokens as $token) {
            if (is_string($token)) {
                // Simple one character token.
                $id = -1;
                $text = $token;
            } else {
                // Token array.
                list($id, $text) = $token;
            }
            switch ($id) {
                case T_WHITESPACE:
                case T_COMMENT:
                case T_ML_COMMENT:
                case T_DOC_COMMENT:
                    // Ignore whitespaces, inline comments, multiline comments and docblocks.
                    break;
                case T_OPEN_TAG:
                    // Start processing.
                    $doprocess = true;
                    break;
                case T_CLOSE_TAG:
                    // Stop processing.
                    $doprocess = false;
                    break;
                default:
                    // Anything else is within PHP tags, return it as is.
                    if ($doprocess) {
                        $output .= $text;
                        if ($text === 'function') {
                            // Explicitly keep the whitespace that would be ignored.
                            $output .= ' ';
                        }
                    }
                    break;
            }
        }

        return $output;
    }
969423
public function parse()
    {
        try {
            $this->ensureFileIsReadable();
        } catch (InvalidPathException $e) {
            return [];
        }

        $filePath = $this->filePath;
        $lines = $this->readLinesFromFile($filePath);

        $data = [];
        foreach ($lines as $line) {
            if (!$this->isComment($line) && $this->looksLikeSetter($line)) {
                list($name, $value) = $this->processFilters($line, null);
                $data[$name] = $value;
            }
        }

        return $data;
    }
1313327
public function read($path)
    {
        list (, $fileId) = $this->splitPath($path);
        if ($response = $this->service->files->get($fileId, $this->applyDefaultParams([
            'alt' => 'media'
        ], 'files.get'))) {
            return [
                'contents' => (string) $response->getBody()
            ];
        }

        return false;
    }
357903
private function loadLangFile($fullPath)
    {
        //====================================================================//
        // Check if File Exists
        if (!is_file($fullPath)) {
            return false;
        }

        //====================================================================//
        // Open File
        $file = @fopen($fullPath, "rt");
        if (!$file) {
            return false;
        }

        //====================================================================//
        // Import All New Translation Keys
        // Ex: Need 225ms for all fgets on all lang file for Third party page. Same speed than file_get_contents
        while ($line = fgets($file, 4096)) {
            $this->loadLangLine($line);
        }

        //====================================================================//
        // Close File
        fclose($file);
    }
603509
protected function parsePseudoIniFile($filepath)
    {
        $properties = array();
        if (($lines = @file($filepath)) === false) {
            throw new Exception("Unable to parse contents of $filepath");
        }
        foreach ($lines as $line) {
            $line = trim($line);
            if ($line == "" || $line{0} == '#' || $line{0} == ';') {
                continue;
            }
            $pos = strpos($line, '=');
            $property = trim(substr($line, 0, $pos));
            $value = trim(substr($line, $pos + 1));
            if ($value === "true") {
                $value = true;
            } elseif ($value === "false") {
                $value = false;
            }
            $properties[$property] = $value;
        }

        return $properties;
    }
242707
public function ls(string $path): array
    {
        $files = [];
        $d = dir($path);
        while (false !== ($entry = $d->read())) {
            if (in_array($entry, ['.', '..'], true)) {
                continue;
            }
            $entryPath = $path . $entry;
            if (is_dir($entryPath)) {
                foreach ($this->ls($entryPath . DIRECTORY_SEPARATOR) as $entryPath) {
                    $files[] = $entryPath;
                }
                continue;
            }
            if (!is_file($entryPath)) {
                continue;
            }
            $files[] = $entryPath;
        }
        $d->close();

        return $files;
    }
678392
public static function splitNameFromPath($path)
    {
        $name = static::nameFromPath($path);
        $path = static::trimFileName($path);

        return [$path, $name];
    }
740244
private function getFiles($path)
    {
        if (is_file($path)) {
            return [new SplFileInfo($path, '', '')];
        }

        return $this->finder->name('*.php')->in(realpath($path));
    }
497207
public function readSynonymsFromFile(string $filepath): array
    {
        if (
            !is_file($filepath) ||
            !is_readable($filepath)
        ) {
            throw SynonymsException::synonymsFileNotFound($filepath);
        }

        $data = file_get_contents($filepath);

        if (!is_string($data)) {
            throw SynonymsException::synonymsMalformedData($filepath);
        }

        return array_filter(array_map(function ($line) {
            if (!is_string($line)) {
                return false;
            }

            $words = str_getcsv($line, ',');

            if (count($words) <= 1) {
                return false;
            }

            return Synonym::createByWords($words);
        }, str_getcsv($data, "\n")));
    }
1243167
private function loadLocaleFiles($path)
    {
        $files = [];

        foreach ($this->filesystem->allFiles($path) as $file) {
            /** @var \Symfony\Component\Finder\SplFileInfo $file */
            $key = str_replace(
                ['.php', DS], ['', '.'], $file->getRelativePathname()
            );

            $files[$key] = [
                'path'    => $file->getRealPath(),
                'content' => $this->filesystem->getRequire($file),
            ];
        }

        return $files;
    }
1211931
static public function getRelPath(string $fullPath): string {
        $contDir = RC::get('containerDir');
        if (!strpos($fullPath, $contDir) === 0) {
            throw new InvalidArgumentException('path is outside the container');
        }
        $contDir = preg_replace('|/$|', '', $contDir);
        return substr($fullPath, strlen($contDir) + 1);
    }
24322
private static function readRaw($realPath)
    {
        $content = @file_get_contents($realPath);

        if (false === $content) {
            $error = error_get_last();

            throw new \RuntimeException(sprintf(
                'Failed to read content from "%s".%s',
                $realPath,
                $error ? ' '.$error['message'] : ''
            ));
        }

        return $content;
    }
729951
public function read($path) {
        $mapping = $this->mapper->get($path);

        if (!$mapping) {
            return false;
        }

        try {
            $file = $this->client->get($mapping['fid']);

            if (!$file) {
                return false;
            }

            return [
                'contents' => stream_get_contents($file)
            ];
        } catch (SeaweedFSException $e) {
            return false;
        }
    }
472343
public function read($path)
    {
        try {
            $response = $this->forceReadFromCDN()
                ? $this->readFromCDN($path)
                : $this->readFromSource($path);

            return ['contents' => (string) $response];
        } catch (NoSuchKeyException $e) {
            return false;
        } catch (\GuzzleHttp\Exception\ClientException $e) {
            return false;
        }
    }