Code Duplication    Length = 17-17 lines in 2 locations

src/Config.php 1 location

@@ 56-72 (lines=17) @@
53
     * @param string $file
54
     * @return array $config
55
     */
56
    public static function getConfigFile($file): array
57
    {
58
        $file = addslashes($file);
59
        if (is_file($file)) {
60
            $data = str_replace("\\", "\\\\", file_get_contents($file));
61
            $json = json_decode($data, true);
62
63
            if (empty($json)) {
64
                throw new \Exception("Config file has a json parse error, $file");
65
            }
66
67
        } else {
68
            throw new \Exception("Config file not found, $file");
69
        }
70
        
71
        return $json;
72
    }
73
}

src/Helper.php 1 location

@@ 71-87 (lines=17) @@
68
     * @param string $file
69
     * @return array $config
70
     */
71
    public static function getConfigFile($filename)
72
    {
73
        $filename = addslashes($filename);
74
        if (is_file($filename)) {
75
            $data = str_replace("\\", "\\\\", file_get_contents($filename));
76
            $json = json_decode($data, true);
77
78
            if (empty($json)) {
79
                throw new \Exception("Config file has a json parse error, $filename");
80
            }
81
82
        } else {
83
            throw new \Exception("Config file not found, $filename");
84
        }
85
        
86
        return $json;
87
    }
88
    
89
    /**
90
     * Get configuration