1
0
Fork 0
composer/src/Composer/Composer.php

74 lines
1.6 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer;
2011-09-17 11:18:34 +00:00
use Composer\Installer\InstallerInterface;
2011-09-21 21:02:58 +00:00
use Composer\Repository\RepositoryInterface;
/**
* @author Jordi Boggiano <j.boggiano@seld.be>
2011-09-16 19:14:06 +00:00
* @author Konstantin Kudryashiv <ever.zet@gmail.com>
*/
class Composer
{
const VERSION = '1.0.0-DEV';
2011-09-16 19:14:06 +00:00
private $repositories = array();
private $installers = array();
2011-09-16 19:14:06 +00:00
public function setInstaller($type, InstallerInterface $installer = null)
{
2011-09-16 19:14:06 +00:00
if (null === $installer) {
unset($this->installers[$type]);
2011-09-16 19:14:06 +00:00
return;
}
$this->installers[$type] = $installer;
}
public function getInstaller($type)
{
if (!isset($this->installers[$type])) {
throw new \UnexpectedValueException('Unknown dependency type: '.$type);
}
2011-09-16 19:14:06 +00:00
return $this->installers[$type];
}
2011-09-16 19:14:06 +00:00
public function setRepository($name, RepositoryInterface $repository = null)
{
2011-09-16 19:14:06 +00:00
if (null === $repository) {
unset($this->repositories[$name]);
2011-09-16 19:14:06 +00:00
return;
}
2011-09-16 19:14:06 +00:00
$this->repositories[$name] = $repository;
}
2011-09-16 19:14:06 +00:00
public function getRepository($name)
{
2011-09-16 19:14:06 +00:00
if (!isset($this->repositories[$name])) {
throw new \UnexpectedValueException('Unknown repository: '.$name);
2011-06-06 09:06:59 +00:00
}
2011-09-16 19:14:06 +00:00
return $this->repositories[$name];
}
2011-09-16 19:14:06 +00:00
public function getRepositories()
{
return $this->repositories;
}
2011-09-17 11:18:34 +00:00
}