public static function register($scheme, $repositoryFactory)
    {
        if (!$repositoryFactory instanceof ResourceRepository
                && !is_callable($repositoryFactory)) {
            throw new InvalidArgumentException(sprintf(
                'The repository factory should be a callable or an instance '.
                'of ResourceRepository. Got: %s',
                $repositoryFactory
            ));
        }

        Assert::string($scheme, 'The scheme must be a string. Got: %s');
        Assert::alnum($scheme, 'The scheme %s should consist of letters and digits only.');
        Assert::startsWithLetter($scheme, 'The scheme %s should start with a letter.');

        if (isset(self::$repos[$scheme])) {
            throw new StreamWrapperException(sprintf(
                'The scheme "%s" has already been registered.',
                $scheme
            ));
        }

        self::$repos[$scheme] = $repositoryFactory;

        stream_wrapper_register($scheme, __CLASS__);
    }
public static function register($scheme, $repositoryFactory)
    {
        if (!$repositoryFactory instanceof ResourceRepository
                && !is_callable($repositoryFactory)) {
            throw new InvalidArgumentException(sprintf(
                'The repository factory should be a callable or an instance '.
                'of ResourceRepository. Got: %s',
                $repositoryFactory
            ));
        }

        Assert::string($scheme, 'The scheme must be a string. Got: %s');
        Assert::alnum($scheme, 'The scheme %s should consist of letters and digits only.');
        Assert::startsWithLetter($scheme, 'The scheme %s should start with a letter.');

        if (isset(self::$repos[$scheme])) {
            throw new StreamWrapperException(sprintf(
                'The scheme "%s" has already been registered.',
                $scheme
            ));
        }

        self::$repos[$scheme] = $repositoryFactory;

        stream_wrapper_register($scheme, __CLASS__);
    }
public static function register ( $ scheme , $ repositoryFactory ) { if ( ! $ repositoryFactory instanceof ResourceRepository && ! is_callable ( $ repositoryFactory ) ) { throw new InvalidArgumentException ( sprintf ( 'The repository factory should be a callable or an instance ' . 'of ResourceRepository. Got: %s' , $ repositoryFactory ) ) ; } Assert :: string ( $ scheme , 'The scheme must be a string. Got: %s' ) ; Assert :: alnum ( $ scheme , 'The scheme %s should consist of letters and digits only.' ) ; Assert :: startsWithLetter ( $ scheme , 'The scheme %s should start with a letter.' ) ; if ( isset ( self :: $ repos [ $ scheme ] ) ) { throw new StreamWrapperException ( sprintf ( 'The scheme "%s" has already been registered.' , $ scheme ) ) ; } self :: $ repos [ $ scheme ] = $ repositoryFactory ; stream_wrapper_register ( $ scheme , __CLASS__ ) ; }
Registers a repository as PHP stream wrapper.

The resources of the repository can subsequently be accessed with PHP's
file system by prefixing the resource paths with the registered URI
scheme:

```php
ResourceStreamWrapper::register('puli', $repo);

// /app/css/style.css
$contents = file_get_contents('puli:///app/css/style.css');
```

Instead of passing a repository, you can also pass a callable. The
callable is executed when the repository is accessed for the first time
and should return a valid {@link ResourceRepository} instance.

@param string                      $scheme            The URI scheme.
@param ResourceRepository|callable $repositoryFactory The repository to use.

@throws StreamWrapperException If a repository was previously registered
for the same scheme. Call
{@link unregister()} to unregister the
scheme first.
Registers a repository as PHP stream wrapper .