<commit_before><?php
/**
 * BEAR.Resource;
 *
 * @package BEAR.Resource
 * @license http://opensource.org/licenses/bsd-license.php BSD
 */
namespace BEAR\Resource;

use BEAR\Resource\Object as ResourceObject,
    Ray\Di\InjectorInterface;

/**
 * Resource object factory.
 *
 * @package BEAR.Resource
 * @author  <NAME> <<EMAIL>>
 *
 * @Scope("singleton")
 */
class Factory implements ResourceFactory
{
    /**
     * Resource adapter
     *
     * @var array
     */
    private $resourceAdapters = array();

    /**
     * Construcotr
     *
     * @param InjectorInterface $injector
     * @param array             $resourceAdapters
     *
     * @Inject
     * @Named("resourceAdapters=ResourceAdapters")
     */
    public function __construct(InjectorInterface $injector, array $resourceAdapters)
    {
        $this->injector = $injector;
        $this->resourceAdapters = $resourceAdapters;
    }

    /**
     * (non-PHPdoc)
     * @see BEAR\Resource.ResourceFactory::newInstance()
     * @throws Exception\InvalidScheme
     */
    public function newInstance($uri)
    {
        $scheme = parse_url($uri)['scheme'];
        if (!isset($this->resourceAdapters[$scheme])) {
            throw new Exception\InvalidScheme($scheme);<commit_msg>For PHP5.3.<commit_after><?php
/**
 * BEAR.Resource;
 *
 * @package BEAR.Resource
 * @license http://opensource.org/licenses/bsd-license.php BSD
 */
namespace BEAR\Resource;

use BEAR\Resource\Object as ResourceObject,
    Ray\Di\InjectorInterface;

/**
 * Resource object factory.
 *
 * @package BEAR.Resource
 * @author  <NAME> <<EMAIL>>
 *
 * @Scope("singleton")
 */
class Factory implements ResourceFactory
{
    /**
     * Resource adapter
     *
     * @var array
     */
    private $resourceAdapters = array();

    /**
     * Construcotr
     *
     * @param InjectorInterface $injector
     * @param array             $resourceAdapters
     *
     * @Inject
     * @Named("resourceAdapters=ResourceAdapters")
     */
    public function __construct(InjectorInterface $injector, array $resourceAdapters)
    {
        $this->injector = $injector;
        $this->resourceAdapters = $resourceAdapters;
    }

    /**
     * (non-PHPdoc)
     * @see BEAR\Resource.ResourceFactory::newInstance()
     * @throws Exception\InvalidScheme
     */
    public function newInstance($uri)
    {
        $parsedUrl = parse_url($uri);
        $scheme = $parsedUrl['scheme'];
        if (!isset($this->resourceAdapters[$scheme])) {
            throw new Exception\InvalidScheme($scheme);
{'fraction_non_alphanumeric': 0.13591465823785065, 'fraction_numerical': 0.0007902015013828526, 'mean_word_length': 2.685589519650655, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '3659101', 'n_tokens_mistral': 768, 'n_tokens_neox': 753, 'n_words': 138}