<commit_before><?php

namespace vierbergenlars\SemVer;

class version extends expression {

    private $version = '0.0.0';
    private $major = '0';
    private $minor = '0';
    private $patch = '0';
    private $build = '';
    private $prtag = '';

    /**
     * Initializes the version object with a simple version
     * @param string $version A simple, single version string
     * @throws SemVerException 
     */
    function __construct($version) {
        $version = (string) $version;
        $expression = sprintf(parent::$dirty_regexp_mask, parent::$global_single_version);
      	if(!preg_match($expression, $version, $matches)) {
            throw new SemVerException('This is not a valid version');
	}

        parent::matchesToVersionParts($matches, $this->major, $this->minor, $this->patch, $this->build, $this->prtag, NULL);

        if($this->build === '') 
        $this->build = null;
	$this->version = parent::constructVersionFromParts(false, $this->major, $this->minor, $this->patch, $this->build, $this->prtag);

        if ($this->major === null)
            $this->major = -1;
        if ($this->minor === null)
            $this->minor = -1;
        if ($this->patch === null)
            $this->patch = -1;
        if ($this->build === null)
            $this->build = -1;

    }



    /**
     * Get the full version
     * @return string 
     */
    function getVersion() {
        return (string)$this->version;
    }

    /**
     * Get the major version number
     * @return int<commit_msg>Add option to pad the missing parts with zero in the version<commit_after><?php

namespace vierbergenlars\SemVer;

class version extends expression {

    private $version = '0.0.0';
    private $major = '0';
    private $minor = '0';
    private $patch = '0';
    private $build = '';
    private $prtag = '';

    /**
     * Initializes the version object with a simple version
     * @param string $version A simple, single version string
     * @param bool $padZero Set empty version pieces to zero?
     * @throws SemVerException 
     */
    function __construct($version, $padZero=false) {
        $version = (string) $version;
        $expression = sprintf(parent::$dirty_regexp_mask, parent::$global_single_version);
      	if(!preg_match($expression, $version, $matches)) {
            throw new SemVerException('This is not a valid version');
	}

        parent::matchesToVersionParts($matches, $this->major, $this->minor, $this->patch, $this->build, $this->prtag, $padZero?0:null);

        if($this->build === '') 
        $this->build = null;
	$this->version = parent::constructVersionFromParts($padZero, $this->major, $this->minor, $this->patch, $this->build, $this->prtag);

        if ($this->major === null)
            $this->major = -1;
        if ($this->minor === null)
            $this->minor = -1;
        if ($this->patch === null)
            $this->patch = -1;
        if ($this->build === null)
            $this->build = -1;

    }



    /**
     * Get the full version
     * @return string 
     */
    function getVersion() {
        return (string)$this->version;
    }

    /**
     * Get the major version number
     * @return int
{'fraction_non_alphanumeric': 0.1554582421019706, 'fraction_numerical': 0.0065686581169846735, 'mean_word_length': 2.4535637149028076, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4723813', 'n_tokens_mistral': 961, 'n_tokens_neox': 934, 'n_words': 248}