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

Latest commit

 

History

History
39 lines (30 loc) · 745 Bytes

03-Dumping.md

File metadata and controls

39 lines (30 loc) · 745 Bytes

Dumping

To dump a Herrera\Version\Version instance as a string, you will need to use the Herrera\Version\Dumper::toString() method:

use Herrera\Version\Dumper;
use Herrera\Version\Version;

$version = new Version(
    1,
    2,
    3,
    array('alpha', '1'),
    array('2')
);

echo Dumper::toString($version); // echoes "1.2.3-alpha.1+2"

If you need the version data as a simple array, you may use the toComponents() method:

use Herrera\Version\Parser;

$components = Dumper::toComponents($version);

// is the equivalent to:

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