Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/flexible-shipping-pro   php

Repository URL to install this package:

Version: 1.11.1 

/ wpdesk / wp-codeception / src / WPDesk / Composer / Commands / SedTrait.php

<?php

namespace FSProVendor\WPDesk\Composer\Codeception\Commands;

/**
 * Trait with a sed like command
 * @see https://pl.wikipedia.org/wiki/Sed_(program)
 *
 * @package WPDesk\Composer\GitPlugin\Command
 */
trait SedTrait
{
    /**
     * SED.
     *
     * @param string $file_pattern .
     * @param string $pattern .
     * @param string $replace .
     *
     * @return string[] array of changed files
     */
    private function wpdeskSed($file_pattern, $pattern, $replace)
    {
        $changed_files = [];
        foreach (\glob($file_pattern) as $filename) {
            $input = \file_get_contents($filename);
            $output = \preg_replace($pattern, $replace, $input);
            if ($output !== $input) {
                $changed_files[] = $filename;
                \file_put_contents($filename, $output);
            }
        }
        return $changed_files;
    }
}