Code Duplication    Length = 11-18 lines in 3 locations

src/Phinx/Config/Config.php 3 locations

@@ 79-91 (lines=13) @@
76
     * @throws \RuntimeException
77
     * @return Config
78
     */
79
    public static function fromYaml($configFilePath)
80
    {
81
        $configFile = file_get_contents($configFilePath);
82
        $configArray = Yaml::parse($configFile);
83
84
        if (!is_array($configArray)) {
85
            throw new \RuntimeException(sprintf(
86
                'File \'%s\' must be valid YAML',
87
                $configFilePath
88
            ));
89
        }
90
        return new static($configArray, $configFilePath);
91
    }
92
93
    /**
94
     * Create a new instance of the config class using a JSON file path.
@@ 100-110 (lines=11) @@
97
     * @throws \RuntimeException
98
     * @return Config
99
     */
100
    public static function fromJson($configFilePath)
101
    {
102
        $configArray = json_decode(file_get_contents($configFilePath), true);
103
        if (!is_array($configArray)) {
104
            throw new \RuntimeException(sprintf(
105
                'File \'%s\' must be valid JSON',
106
                $configFilePath
107
            ));
108
        }
109
        return new static($configArray, $configFilePath);
110
    }
111
112
    /**
113
     * Create a new instance of the config class using a PHP file path.
@@ 119-136 (lines=18) @@
116
     * @throws \RuntimeException
117
     * @return Config
118
     */
119
    public static function fromPhp($configFilePath)
120
    {
121
        ob_start();
122
        /** @noinspection PhpIncludeInspection */
123
        $configArray = include($configFilePath);
124
125
        // Hide console output
126
        ob_end_clean();
127
128
        if (!is_array($configArray)) {
129
            throw new \RuntimeException(sprintf(
130
                'PHP file \'%s\' must return an array',
131
                $configFilePath
132
            ));
133
        }
134
135
        return new static($configArray, $configFilePath);
136
    }
137
138
    /**
139
     * {@inheritdoc}