<commit_before><?php

/*
 * This file is part of Composer.
 *
 * (c) <NAME> <<EMAIL>>
 *     <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer;

use Composer\Repository\ComposerRepository;
use Composer\Repository\PlatformRepository;
use Composer\Repository\GitRepository;
use Composer\Repository\PearRepository;

/**
 * @author <NAME> <<EMAIL>>
 */
class Composer
{
    protected $repositories = array();
    protected $downloaders = array();
    protected $installers = array();

    public function __construct()
    {
        $this->addRepository('Packagist', array('composer' => 'http://packagist.org'));
        $this->addRepository('Platform', array('platform' => ''));
    }

    public function addDownloader($type, $downloader)
    {
        $this->downloaders[$type] = $downloader;
    }

    public function getDownloader($type)
    {
        if (!isset($this->downloaders[$type])) {
            throw new \UnexpectedValueException('Unknown source type: '.$type);
        }
        return $this->downloaders[$type];
    }

    public function addInstaller($type, $installer)
    {
        $this->installers[$type] = $installer;
    }

    public function getInstaller($type)
    {
        if (!isset($this->installers[$type])) {
            throw new \UnexpectedValueException('Unknown dependency type: '.$type);
        }
        return $this->installers[$type];
    }

    public function addRepository($name, $spec)
    {
        if (null === $spec) {
            unset($this->repositories[$name]);
        }
        if (is_array($spec) && count($spec)) {
            return $this->repositories[$name] = $this->createRepository($name, key($spec), current($spec));
        }
        throw new \UnexpectedValueException('Invalid repositories specification '.var_export($spec, true));
    }

    public function getRepositories()
    {
        return $this->repositories;
    }

    public function createRepository($name, $type, $spec)
    {<commit_msg>Better error reporting for incorrect repo specs<commit_after><?php

/*
 * This file is part of Composer.
 *
 * (c) <NAME> <<EMAIL>>
 *     <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer;

use Composer\Repository\ComposerRepository;
use Composer\Repository\PlatformRepository;
use Composer\Repository\GitRepository;
use Composer\Repository\PearRepository;

/**
 * @author <NAME> <<EMAIL>>
 */
class Composer
{
    protected $repositories = array();
    protected $downloaders = array();
    protected $installers = array();

    public function __construct()
    {
        $this->addRepository('Packagist', array('composer' => 'http://packagist.org'));
        $this->addRepository('Platform', array('platform' => ''));
    }

    public function addDownloader($type, $downloader)
    {
        $this->downloaders[$type] = $downloader;
    }

    public function getDownloader($type)
    {
        if (!isset($this->downloaders[$type])) {
            throw new \UnexpectedValueException('Unknown source type: '.$type);
        }
        return $this->downloaders[$type];
    }

    public function addInstaller($type, $installer)
    {
        $this->installers[$type] = $installer;
    }

    public function getInstaller($type)
    {
        if (!isset($this->installers[$type])) {
            throw new \UnexpectedValueException('Unknown dependency type: '.$type);
        }
        return $this->installers[$type];
    }

    public function addRepository($name, $spec)
    {
        if (null === $spec) {
            unset($this->repositories[$name]);
        }
        if (is_array($spec) && count($spec) === 1) {
            return $this->repositories[$name] = $this->createRepository($name, key($spec), current($spec));
        }
        throw new \UnexpectedValueException('Invalid repositories specification '.json_encode($spec).', should be: {"type": "url"}');
    }

    public function getRepositories()
    {
        return $this->repositories;
    }

    public function createRepository($name, $type, $spec)
    {
{'fraction_non_alphanumeric': 0.1458235016517225, 'fraction_numerical': 0.00023596035865974517, 'mean_word_length': 3.018009478672986, 'pattern_counts': {'":': 1, '<': 23, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7026544', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1168, 'n_words': 278}