Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Latest commit

 

History

History
49 lines (35 loc) · 1006 Bytes

04-Parsing.md

File metadata and controls

49 lines (35 loc) · 1006 Bytes

Parsing

There are three ways of parsing version information with the Herrera\Version\Parser class.

String to Builder

  • Herrera\Version\Builder toBuilder(str $version)

The toBuilder() method will return a version builder for the given string representation:

use Herrera\Version\Parser;

$builder = Parser::toBuilder('1.0.0-alpha.1+2');

String to Components

If you just need the version string broken down into its components, you may use the toComponenets() method:

$componenets = Parser::toComponents('1.0.0-alpha.1+2');

// is the equivalent to:

$components = array(
    Parser::MAJOR => 1,
    Parser::MINOR => 0,
    Parser::PATCH => 0,
    Parser::PRE_RELEASE => array('alpha', '1'),
    Parser::BUILD => array('2')
);

String to Version

If you simply need an instance of Herrera\Version\Version, you may use the toVersion() method:

$version = Parser::toVersion('1.0.0-alpha.1+2');