<commit_before><?php declare(strict_types=1);

namespace Packagist\WebBundle\Util;

class UserAgentParser
{
    /** @var ?string */
    private $composerVersion;
    /** @var ?string */
    private $phpVersion;
    /** @var ?string */
    private $os;
    /** @var ?string */
    private $httpVersion;
    /** @var ?bool */
    private $ci;

    public function __construct(?string $userAgent)
    {
        if ($userAgent && preg_match('#^Composer/(?P<composer>[a-z0-9.+-]+) \((?P<os>\S+).*?; PHP (?P<php>[0-9.]+)[^;]*(?:; (?P<http>streams|curl [0-9.]+)[^;]*)?(?P<ci>; CI)?#i', $userAgent, $matches)) {
            if ($matches['composer'] === 'source' || preg_match('{^[a-f0-9]{40}$}', $matches['composer'])) {
                $matches['composer'] = 'pre-1.8.5';
            }
            $this->composerVersion = preg_replace('{\+[a-f0-9]{40}}', '', $matches['composer']);
            $this->phpVersion = $matches['php'];
            $this->os = preg_replace('{^cygwin_nt-.*}', 'cygwin', strtolower($matches['os']));
            $this->httpVersion = $matches['http'] ?? null;
            $this->ci = (bool) ($matches['ci'] ?? null);
        }
    }

    public function getComposerVersion(): ?string
    {<commit_msg>Only track curl minor version, ignore patch<commit_after><?php declare(strict_types=1);

namespace Packagist\WebBundle\Util;

class UserAgentParser
{
    /** @var ?string */
    private $composerVersion;
    /** @var ?string */
    private $phpVersion;
    /** @var ?string */
    private $os;
    /** @var ?string */
    private $httpVersion;
    /** @var ?bool */
    private $ci;

    public function __construct(?string $userAgent)
    {
        if ($userAgent && preg_match('#^Composer/(?P<composer>[a-z0-9.+-]+) \((?P<os>\S+).*?; PHP (?P<php>[0-9.]+)[^;]*(?:; (?P<http>streams|curl \d+\.\d+)[^;]*)?(?P<ci>; CI)?#i', $userAgent, $matches)) {
            if ($matches['composer'] === 'source' || preg_match('{^[a-f0-9]{40}$}', $matches['composer'])) {
                $matches['composer'] = 'pre-1.8.5';
            }
            $this->composerVersion = preg_replace('{\+[a-f0-9]{40}}', '', $matches['composer']);
            $this->phpVersion = $matches['php'];
            $this->os = preg_replace('{^cygwin_nt-.*}', 'cygwin', strtolower($matches['os']));
            $this->httpVersion = $matches['http'] ?? null;
            $this->ci = (bool) ($matches['ci'] ?? null);
        }
    }

    public function getComposerVersion(): ?string
    {
{'fraction_non_alphanumeric': 0.24200728450020234, 'fraction_numerical': 0.013759611493322542, 'mean_word_length': 2.856474258970359, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '1783055', 'n_tokens_mistral': 872, 'n_tokens_neox': 853, 'n_words': 142}