Code Duplication    Length = 5-6 lines in 2 locations

src/Result/MessageLocator.php 1 location

@@ 202-207 (lines=6) @@
199
    public static function fromJsonFile($file)
200
    {
201
        if (is_readable($file) && is_file($file)) {
202
            if (($jsonData = json_decode(file_get_contents($file), true)) !== null) {
203
                return static::fromArray($jsonData);
204
            } else {
205
                throw new \InvalidArgumentException(sprintf("%s could not be parsed as json file. Last json error message was\n%s",
206
                    $file, version_compare(PHP_VERSION, '5.5.0', '>=') ? json_last_error_msg() : json_last_error()));
207
            }
208
        } else {
209
            throw new \InvalidArgumentException(sprintf('%s is not a valid file', $file));
210
        }

src/Console/Commands/PvraBaseCommand.php 1 location

@@ 228-232 (lines=5) @@
225
                case 'php':
226
                    return [$type, include $filePath];
227
                case 'json':
228
                    if (($data = json_decode(file_get_contents($filePath), true)) === null) {
229
                        throw new \RuntimeException(sprintf('Json decoding of file "%s" failed with notice: "%s"',
230
                            $filePath,
231
                            version_compare(PHP_VERSION, '5.5.0', '>=') ? json_last_error_msg() : json_last_error()));
232
                    }
233
                    return [$type, $data];
234
                default:
235
                    throw new \InvalidArgumentException(sprintf('The %s filetype is not supported. Only php and json files are supported for this operation.',