Potsky\LaravelLocalizationHelpers\Factory\Localization::extractTranslationFromPhpFile PHP Method

extractTranslationFromPhpFile() public method

Remove all translations containing : - $ -> auto-generated translation cannot be supported - :: -> package translations are not taken in account
public extractTranslationFromPhpFile ( string $path, array $trans_methods ) : array
$path string the file path
$trans_methods array an array of regex to catch
return array an array dot of found translations
    public function extractTranslationFromPhpFile($path, $trans_methods)
    {
        $result = array();
        $string = Tools::minifyString(file_get_contents($path));
        foreach (array_flatten($trans_methods) as $method) {
            preg_match_all($method, $string, $matches);
            foreach ($matches[1] as $k => $v) {
                if (strpos($v, '$') !== false) {
                    unset($matches[1][$k]);
                }
                if (strpos($v, '::') !== false) {
                    unset($matches[1][$k]);
                }
            }
            $result = array_merge($result, array_flip($matches[1]));
        }
        return $result;
    }