Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
Cherry pick changes from #9
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Jun 22, 2019
1 parent 7695f03 commit 72b73b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/ResourceLocator.php
Expand Up @@ -11,6 +11,7 @@
namespace UserFrosting\UniformResourceLocator;

use Illuminate\Filesystem\Filesystem;
use InvalidArgumentException;
use RocketTheme\Toolbox\StreamWrapper\Stream;
use RocketTheme\Toolbox\StreamWrapper\StreamBuilder;
use UserFrosting\UniformResourceLocator\Exception\LocationNotFoundException;
Expand Down Expand Up @@ -107,7 +108,7 @@ public function __invoke($uri)
public function addStream(ResourceStreamInterface $stream)
{
if (in_array($stream->getScheme(), $this->reservedStreams)) {
throw new \InvalidArgumentException("Can't add restriced stream scheme {$stream->getScheme()}.");
throw new InvalidArgumentException("Can't add restricted stream scheme {$stream->getScheme()}.");
}

$this->streams[$stream->getScheme()][$stream->getPrefix()][] = $stream;
Expand Down Expand Up @@ -476,6 +477,7 @@ public function normalize($uri, $throwException = false, $splitStream = false)
return false;
}
}

$uri = preg_replace('|\\\|u', $this->separator, $uri);
$segments = explode('://', $uri, 2);
$path = array_pop($segments);
Expand Down Expand Up @@ -568,10 +570,10 @@ public function findResource($uri, $absolute = true, $first = false)
*/
public function findResources($uri, $absolute = true, $all = false)
{
$reources = $this->getResources($uri, $all);
$resources = $this->getResources($uri, $all);

$paths = [];
foreach ($reources as $resource) {
foreach ($resources as $resource) {
if ($absolute) {
$paths[] = $resource->getAbsolutePath();
} else {
Expand Down Expand Up @@ -647,15 +649,15 @@ protected function searchPaths(ResourceStreamInterface $stream)
* @param bool $array Return an array or a single path
* @param bool $all Whether to return all paths even if they don't exist.
*
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*
* @return ResourceInterface|array[ResourceInterface]
*/
protected function find($scheme, $file, $array, $all)
{
// Make sure stream exist
if (!$this->schemeExists($scheme)) {
throw new \InvalidArgumentException("Invalid resource {$scheme}://");
throw new InvalidArgumentException("Invalid resource {$scheme}://");
}

// Prepare result depending on $array parameter
Expand Down
6 changes: 3 additions & 3 deletions tests/ResourceLocatorTest.php
Expand Up @@ -144,7 +144,7 @@ public function testStreamNotFoundException()

/**
* @depends testRegisterStream
* @expectedException InvalidArgumentException
* @expectedException \InvalidArgumentException
*/
public function testAddStreamThrowExceptionOnRestrictedScheme()
{
Expand Down Expand Up @@ -291,7 +291,7 @@ public function testRegisterLocationWithNoPath()
* @depends testAddLocation
* @expectedException \UserFrosting\UniformResourceLocator\Exception\LocationNotFoundException
*/
public function testgetLocationThrowExceptionIfNotFound()
public function testGetLocationThrowExceptionIfNotFound()
{
$locator = new ResourceLocator();
$locator->getLocation('etc');
Expand Down Expand Up @@ -322,7 +322,7 @@ public function testListLocations()
$locator->registerLocation('bar', '/foo');
$locator->registerLocation('foo', '/bar');

// N.B.: Locations are list with the latest one (top prioriry) first
// N.B.: Locations are list with the latest one (top priority) first
$this->assertEquals(['foo', 'bar'], $locator->listLocations());
}

Expand Down

0 comments on commit 72b73b6

Please sign in to comment.