Process the JSON Fields.

@param  string $file

@return string
764354
protected function processJSONFields($file)
    {
        $json = File::get($file);
        $fields = json_decode($json);

        $fieldsString = '';
        foreach ($fields->fields as $field) {
            if ($field->type === 'select' || $field->type === 'enum') {
                $fieldsString .= $field->name . '#' . $field->type . '#options=' . json_encode($field->options) . ';';
            } else {
                $fieldsString .= $field->name . '#' . $field->type . ';';
            }
        }

        $fieldsString = rtrim($fieldsString, ';');

        return $fieldsString;
    }
765525
public function json($file = null) : Json
    {
        if ($file === null) {
            $file = 'module.json';
        }

        return Arr::get($this->moduleJson, $file, function () use ($file) {
            return $this->moduleJson[$file] = new Json($this->getPath() . '/' . $file, $this->app['files']);
        });
    }
53263
protected static function getMaps($file)
    {
        $maps = json_decode(File::get($file), true);

        if (is_null($maps)) {
            throw new Exception('The existing mapping file contains invalid json string. Please fix the file then try again');
        }

        return $maps;
    }
766356
public function analyze_js(string $file): array
  {
    $res = [];
    $js = file_get_contents($file);
    if ( $tmp = \Gettext\Translations::fromJsCodeString($js, [
      'functions' => [
        '_' => 'gettext',
        'bbn._' => 'gettext'
      ],
      'file' => $file
      ]) ){
      foreach ( $tmp->getIterator() as $r => $tr ){
        $res[] = $tr->getOriginal();
      }
      $this->parser->mergeWith($tmp);
    }
    return array_unique($res);
  }
803076
private static function parseRequestedFile(string $file): array
    {
        $file = ltrim($file, '/');

        $moduleConfig = Config::application('module');

        $parts    = explode('/', $file);
        $partsCnt = count($parts);

        if ($partsCnt > 0 && in_array($parts[0], Config::get('divisions'))) {
            $_division = $parts[0];
            $parts     = array_slice($parts, 1);
        } else {
            $_division = '';
        }

        $_module = empty($parts[0])
            ? $moduleConfig['default']
            : $parts[0];

        $_method = $partsCnt < 2 || empty($parts[1])
            ? $moduleConfig['defaultViewsControllerAction']
            : Str::camel($parts[1]);

        $_params = $partsCnt > 2
            ? array_slice($parts, 2)
            : [];

        return [$_division, $_module, $_method, $_params];
    }
775084
public static function parse($file)
    {
        $config_path = self::$config_path == '' ? APP_PATH . '/config/' : self::$config_path;
        if($file == null){
            $file = scandir($config_path);
            foreach ($file as $k => $v)
            {
                unset($file[0], $file[1]);
                if($v == 'routes.php' )
                {
                    unset($file[$k]);
                }
            }
            foreach ($file as $k => $v)
            {
                $name = str_replace('.php', '', $v);
                $file = $config_path . $v;
                $data[$name] = include $file;
            }
        }else{
            $type = $file;
            if(strpos($type, '.')){
                $type = explode('.', $type);
                $file = $config_path . $type[0] . '.php';
                if(!array_key_exists($type[1], self::load($file)))
                {
                    throw new Exception('This configuration [' . self::$config . '] is not supported!');
                }
                $data = self::load($file)[$type[1]];
            }else{
                $file = $config_path . $file . '.php';
                $data = self::load($file);
            }

        }
        return $data;
    }
1055154
public function getBinaryFileData(File $file)
    {
        $url = self::makeUrl(null, $file->uri);
        $data = $this->service->prepAndSend($url, array(200, 204), 'GET', null, true, 'application/json', 'application/' . $file->type);
        return $data;
    }
249409
protected static function load($file)
    {
        if (null !== static::DIRECTORY) {
            return file_get_contents(__DIR__.'/../data/'.static::DIRECTORY.'/'.$file.'.json');
        }

        return file_get_contents(__DIR__.'/../data/'.$file.'.json');
    }
796000
public static function read(string $file = ''): string
    {
        $result = false;
        $file = static::normalizePath($file);

        if (static::exists($file)) {
            $result = @\file_get_contents($file);
        }

        return $result;
    }
613733
private function decode($file)
	{
		$json = @\file_get_contents($file);
		if ($json === false) {
			$this->error = $this->error ?: \error_get_last()['message'];

			return null;
		}

		try {
			return Json::decode($json);
		} catch (JsonException $e) {
			$this->error = $this->error ?: $e->getMessage();

			return null;
		}
	}
719752
private function parseJson(array $files)
    {
        $fixable = 0;
        foreach ($files as $file) {
            foreach ($file['messages'] as $message) {
                if ($message['fixable']) {
                    $fixable++;
                    break;
                }
            }
        }
        return PHP_EOL . json_encode([
            'totals' => [
                'fixable' => $fixable
            ],
            'files' => $files
        ]);
    }
1192667
protected function getFileContents($file)
    {
        $filePath = $this->directory.'/'.$file;

        if (!file_exists($filePath)) {
            throw new InvalidArgumentException("The file [$filePath] does not exist.");
        }

        return json_decode(file_get_contents($filePath), true);
    }
612788
public function analyze_file(string $file): array
  {
    $res = [];
    $ext = bbn\str::file_ext($file);
    if ( \in_array($ext, self::$extensions, true) && is_file($file) ){
      switch ( $ext ){
        case 'html':
          $res = $this->analyze_php($file);
          break;
        case 'php':
          $res = $this->analyze_php($file);
          break;
        case 'js':
          $res = $this->analyze_js($file);
          break;
        /*case 'json':
          $res = $this->analyze_json($file);
          break;*/
      }
    }
    return $res;
  }
1098219
public function show($file)
    {
        $this->manager->resetPath($file);

        if ($this->manager->isFile()) {
            return new Response($this->manager->fileContent(), 200, [
                'Content-Type' => $this->manager->fileMimeType(),
                'Cache-Control' => 'private, max-age=31536000'
            ]);
        }

        return $this->json('File not found.', 404);
    }
427871
public static function file2array($file)
    {
        $aFile = [];
        if ($file instanceof UploadedFile) {
            $aFile = file($file->getRealPath());
        } elseif (is_array($file) && isset($file[0]) && is_string($file[0])) {
            $aFile = $file;
        } elseif (is_string($file) && is_file($file) && file_exists($file)) {
            $aFile = file($file);
        } elseif (is_string($file) && strstr($file, PHP_EOL) !== false) {
            $file_content = explode(PHP_EOL, $file);
            if (empty(end($file_content))) {
                array_pop($file_content);
            }
            reset($file_content);
            $aFile = $file_content;
        }

        return array_map('\ForceUTF8\Encoding::toUTF8', $aFile);
    }
734158
protected function getFile($file)
    {
        $mapping = [
            '%environment%' => $this->runtime->getEnvironment(),
        ];

        if ($this->runtime->getHostName() !== null) {
            $mapping['%host%'] = $this->runtime->getHostName();
        }

        if ($this->runtime->getReleaseId() !== null) {
            $mapping['%release%'] = $this->runtime->getReleaseId();
        }

        $options = $this->getOptions();
        return str_replace(
            array_keys($mapping),
            array_values($mapping),
            $options[$file]
        );
    }
1287552
public function loadFile($file)
    {
        $data = json_decode(file_get_contents($file), true);
        if (json_last_error() != JSON_ERROR_NONE) {
            throw new LoaderException(sprintf("Could not load the JSON file '%s': %s", $file, json_last_error_msg()));
        }
        return $data;
    }