<commit_before><?php

namespace Qafoo\ChangeTrack\Calculator\RevisionLabelProvider;

use Qafoo\ChangeTrack\Calculator\RevisionLabelProvider;
use Qafoo\ChangeTrack\Analyzer\Result\RevisionChanges;
use Qafoo\ChangeTrack\HttpClient;

class GithubIssueLabelProvider implements SelectableLabelProvider
{
    /**
     * @var \Qafoo\ChangeTrack\HttpClient
     */
    private $httpClient;

    /**
     * @var string
     */
    private $issueUrlTemplate;

    /**
     * @var array
     */
    private $labelMap;

    /**
     * @param \Qafoo\ChangeTrack\HttpClient $httpclient
     * @param string $issueUrlTemplate
     * @param array $labelMap
     */
    public function __construct(HttpClient $httpClient, $issueUrlTemplate, array $labelMap)
    {
        $this->httpClient = $httpClient;
        $this->issueUrlTemplate = $issueUrlTemplate;
        $this->labelMap = $labelMap;
    }

    /**
     * @param \Qafoo\Analyzer\Result\RevisionChanges $revisionChanges
     * @return string
     */
    public function provideLabel(RevisionChanges $revisionChanges)
    {
        $issueId = $this->extractRevisionReference($revisionChanges->commitMessage);

        if ($issueId === null) {
            throw new \RuntimeException(
                sprintf(
                    'No issue reference found in commit message "%s" of revision "%s"',
                    $revisionChanges->commitMessage,
                    $revisionChanges->revision
                )
            );
        }

        $labels = $this->fetchGithubIssueLabels($issueId);

        $mappedLabel = $this->mapALabel($labels);

        if ($mappedLabel === null) {
            throw new \RuntimeException(
                'No mapping label found for issue "%s". Issue labels were: "%s"',
                $issueId,
                implode(
                    '", "',
                    array_map(
                        function ($labelData) {
                            return $labelData->name;
                        },
                        $labels
                    )
                )
            );
        }<commit_msg>Fixed: Exception throwing in GithubIssueLabelProvider.<commit_after><?php

namespace Qafoo\ChangeTrack\Calculator\RevisionLabelProvider;

use Qafoo\ChangeTrack\Calculator\RevisionLabelProvider;
use Qafoo\ChangeTrack\Analyzer\Result\RevisionChanges;
use Qafoo\ChangeTrack\HttpClient;

class GithubIssueLabelProvider implements SelectableLabelProvider
{
    /**
     * @var \Qafoo\ChangeTrack\HttpClient
     */
    private $httpClient;

    /**
     * @var string
     */
    private $issueUrlTemplate;

    /**
     * @var array
     */
    private $labelMap;

    /**
     * @param \Qafoo\ChangeTrack\HttpClient $httpclient
     * @param string $issueUrlTemplate
     * @param array $labelMap
     */
    public function __construct(HttpClient $httpClient, $issueUrlTemplate, array $labelMap)
    {
        $this->httpClient = $httpClient;
        $this->issueUrlTemplate = $issueUrlTemplate;
        $this->labelMap = $labelMap;
    }

    /**
     * @param \Qafoo\Analyzer\Result\RevisionChanges $revisionChanges
     * @return string
     */
    public function provideLabel(RevisionChanges $revisionChanges)
    {
        $issueId = $this->extractRevisionReference($revisionChanges->commitMessage);

        if ($issueId === null) {
            throw new \RuntimeException(
                sprintf(
                    'No issue reference found in commit message "%s" of revision "%s"',
                    $revisionChanges->commitMessage,
                    $revisionChanges->revision
                )
            );
        }

        $labels = $this->fetchGithubIssueLabels($issueId);

        $mappedLabel = $this->mapALabel($labels);

        if ($mappedLabel === null) {
            throw new \RuntimeException(
                sprintf(
                    'No mapping label found for issue "%s". Issue labels were: "%s"',
                    $issueId,
                    implode(
                        '", "',
                        array_map(
                            function ($labelData) {
                                return $labelData->name;
                            },
                            $labels
                        )
                    )
                )
            );
        }
{'fraction_non_alphanumeric': 0.10212569316081331, 'fraction_numerical': 0.0, 'mean_word_length': 1.6788366336633664, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3441077', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1093, 'n_words': 219}