Skip to content

add bump method on version #4

@cordoval

Description

@cordoval

does it have support for ->bump(SemVer::MAJOR) or such?

like here https://github.com/vierbergenlars/php-semver/tree/master#functions

https://github.com/vierbergenlars/php-semver/blob/2.x/src/vierbergenlars/SemVer/version.php#L127

<?php

  /**
     * Increment the version number
     * @param  string                         $what One of 'major', 'minor', 'patch' or 'build'
     * @return \vierbergenlars\SemVer\version
     * @throws SemVerException                When an invalid increment value is given
     */
    public function inc($what)
    {
        if ($what == 'major') {
            return new version(($this->major + 1) . '.0.0');
        }
        if ($what == 'minor') {
            return new version($this->major . '.' . ($this->minor + 1) . '.0');
        }
        if ($what == 'patch') {
            return new version($this->major . '.' . $this->minor . '.' . ($this->patch + 1));
        }
        if ($what == 'build') {
            if ($this->build == -1) {
                return new version($this->major . '.' . $this->minor . '.' . $this->patch . '-1');
            }

            return new version($this->major . '.' . $this->minor . '.' . $this->patch . '-' . ($this->build + 1));
        }
        throw new SemVerException('Invalid increment value given', $what);
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions