PHP code example of requtize / semver-converter

1. Go to this page and download the library: Download requtize/semver-converter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

requtize / semver-converter example snippets


$result = (new SemVerConverter)->convert('0.1.0');

// Result
array (size=1)
  0 => 
    array (size=2)
      'from' => 
        array (size=2)
          0 => int 1000000
          1 => string '==' (length=2)
      'to' => 
        array (size=2)
          0 => int 1000000
          1 => string '==' (length=2)

$result = (new SemVerConverter)->convert('>= 1.3.0 < 1.7.0');

// Result
array (size=1)
  0 => 
    array (size=2)
      'from' => 
        array (size=2)
          0 => int 1003000
          1 => string '>=' (length=2)
      'to' => 
        array (size=2)
          0 => int 1007000
          1 => string '<' (length=1)

$result = (new SemVerConverter)->convert('~1.3');

// Result
array (size=1)
  0 => 
    array (size=2)
      'from' => 
        array (size=2)
          0 => int 1003000
          1 => string '>=' (length=2)
      'to' => 
        array (size=2)
          0 => int 2000000
          1 => string '<' (length=1)

$result = (new SemVerConverter)->convert('^1.9 || 3.0.*');

// Result
array (size=2)
  0 => 
    array (size=2)
      'from' => 
        array (size=2)
          0 => int 1009000
          1 => string '>=' (length=2)
      'to' => 
        array (size=2)
          0 => int 2000000
          1 => string '<' (length=1)
  1 => 
    array (size=2)
      'from' => 
        array (size=2)
          0 => int 3000000
          1 => string '>=' (length=2)
      'to' => 
        array (size=2)
          0 => int 3001000
          1 => string '<' (length=1)

new SemVerConverter($zeros, $sections);