Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Nov 22, 2017
1 parent 03ae86f commit cf29b88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
10 changes: 0 additions & 10 deletions src/Illuminate/Contracts/Translation/JsonFileInvalidException.php

This file was deleted.

14 changes: 7 additions & 7 deletions src/Illuminate/Translation/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Illuminate\Translation;

use RuntimeException;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Contracts\Translation\Loader;
use Illuminate\Contracts\Translation\JsonFileInvalidException;

class FileLoader implements Loader
{
Expand Down Expand Up @@ -132,20 +132,20 @@ protected function loadPath($path, $locale, $group)
* @param string $locale
* @return array
*
* @throws \Illuminate\Contracts\Translation\JsonFileInvalidException
* @throws \RuntimeException
*/
protected function loadJsonPaths($locale)
{
return collect(array_merge($this->jsonPaths, [$this->path]))
->reduce(function ($output, $path) use ($locale) {
if ($this->files->exists($full = "{$path}/{$locale}.json")) {
$filecontent = json_decode($this->files->get($full), true);
if (is_null($filecontent) || json_last_error() !== JSON_ERROR_NONE) {
throw new JsonFileInvalidException("{$full} contains an invalid json object.");
$decoded = json_decode($this->files->get($full), true);

if (is_null($decoded) || json_last_error() !== JSON_ERROR_NONE) {
throw new RuntimeException("Translation file [{$full}] contains an invalid JSON structure.");
}

$output = array_merge($output, $filecontent);
$output = array_merge($output, $decoded);
}

return $output;
Expand Down

0 comments on commit cf29b88

Please sign in to comment.