JonathanTorres\Construct\Helpers\Travis::phpVersionsToTest PHP Method

phpVersionsToTest() public method

Get project php versions that will be run on travis ci.
public phpVersionsToTest ( string $projectPhpVersion ) : array
$projectPhpVersion string
return array
    public function phpVersionsToTest($projectPhpVersion)
    {
        $supportedPhpVersions = (new Defaults())->phpVersions;
        $versionsToTest = (new Defaults())->nonSemverPhpVersions;
        $phpVersionsToTest = array_filter($supportedPhpVersions, function ($supportedPhpVersion) use($projectPhpVersion) {
            return version_compare($this->toMinorversion($projectPhpVersion), $this->toMinorversion($supportedPhpVersion), '<=') === true;
        });
        return array_merge($versionsToTest, $phpVersionsToTest);
    }

Usage Example

Example #1
0
 /**
  * Generate .travis.yml file.
  *
  * @return void
  */
 protected function travis()
 {
     $travisHelper = new Travis();
     if ($this->settings->withPhpcsConfiguration()) {
         $file = $this->file->get(__DIR__ . '/stubs/travis.phpcs.stub');
         $phpVersionsToRunOnTravis = $travisHelper->phpVersionsToRun($travisHelper->phpVersionsToTest($this->settings->getPhpVersion()), true);
     } else {
         $file = $this->file->get(__DIR__ . '/stubs/travis.stub');
         $phpVersionsToRunOnTravis = $travisHelper->phpVersionsToRun($travisHelper->phpVersionsToTest($this->settings->getPhpVersion()));
     }
     $content = str_replace('{phpVersions}', $phpVersionsToRunOnTravis, $file);
     $this->file->put($this->projectLower . '/' . '.travis.yml', $content);
     $this->exportIgnores[] = '.travis.yml';
 }