<commit_before><?php

namespace ThinFrame\Foundation\Version;

use ThinFrame\Foundation\Exceptions\InvalidArgumentException;

/**
 * Class Version
 *
 * @package ThinFrame\Foundation\Version
 * @since   0.2
 */
class Version implements VersionInterface
{
    /**
     * @var string
     */
    protected $versionString;
    /**
     * @var int
     */
    protected $major = 0;
    /**
     * @var int
     */
    protected $minor = 0;
    /**
     * @var int
     */
    protected $release = 0;
    /**
     * @var string
     */
    protected $sufix = '';

    /**
     * @param string $versionString
     */
    public function __construct($versionString)
    {
        $this->versionString = $versionString;
        $this->parseVersion();
    }

    /**
     * Parse version string
     *
     * @throws \ThinFrame\Foundation\Exceptions\InvalidArgumentException
     */
    private function parseVersion()
    {
        if (strstr($this->versionString, '-')) {
            if (sscanf(
                    $this->versionString,
                    '%d.%d.%d-%s',
                    $this->major,
                    $this->minor,
                    $this->release,
                    $this->sufix
                ) != 4
            ) {
                throw new InvalidArgumentException('Invalid version format ' . $this->versionString);
            }
        } else {
            if (sscanf($this->versionString, '%d.%d.%d', $this->major, $this->minor, $this->release) != 3) {
                throw new InvalidArgumentException('Invalid version format ' . $this->versionString);
            }
        }
    }<commit_msg>Fixed version bug<commit_after><?php

namespace ThinFrame\Foundation\Version;

use Stringy\StaticStringy;
use ThinFrame\Foundation\Exceptions\InvalidArgumentException;

/**
 * Class Version
 *
 * @package ThinFrame\Foundation\Version
 * @since   0.2
 */
class Version implements VersionInterface
{
    /**
     * @var string
     */
    protected $versionString;
    /**
     * @var int
     */
    protected $major = 0;
    /**
     * @var int
     */
    protected $minor = 0;
    /**
     * @var int
     */
    protected $release = 0;
    /**
     * @var string
     */
    protected $sufix = '';

    /**
     * @param string $versionString
     */
    public function __construct($versionString)
    {
        $this->versionString = trim($versionString);
        $this->parseVersion();
    }

    /**
     * Parse version string
     *
     * @throws \ThinFrame\Foundation\Exceptions\InvalidArgumentException
     */
    private function parseVersion()
    {
        if (StaticStringy::startsWith($this->versionString, 'v')) {
            $this->versionString = StaticStringy::substr($this->versionString, 1);
        }
        if (strstr($this->versionString, '-')) {
            if (sscanf(
                    $this->versionString,
                    '%d.%d.%d-%s',
                    $this->major,
                    $this->minor,
                    $this->release,
                    $this->sufix
                ) != 4
            ) {
                throw new InvalidArgumentException('Invalid version format ' . $this->versionString);
            }
        } else {
            if (sscanf($this->versionString, '%d.%d.%d', $this->major, $this->minor, $this->release) != 3) {
                throw new InvalidArgumentException('Invalid version format ' . $this->versionString);
            }
        }
    }
{'fraction_non_alphanumeric': 0.13702201622247973, 'fraction_numerical': 0.004345307068366165, 'mean_word_length': 1.6684698608964452, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, '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': '3065278', 'n_tokens_mistral': 989, 'n_tokens_neox': 936, 'n_words': 182}