Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Fix CS issues
Browse files Browse the repository at this point in the history
- indentation, trailing speces
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
30 changes: 15 additions & 15 deletions src/UriFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function unregisterScheme($scheme)
{
$scheme = strtolower($scheme);
if (isset(static::$schemeClasses[$scheme])) {
unset(static::$schemeClasses[$scheme]);
unset(static::$schemeClasses[$scheme]);
}
}

Expand Down Expand Up @@ -90,23 +90,23 @@ public static function factory($uriString, $defaultScheme = null)
}

if ($scheme && ! isset(static::$schemeClasses[$scheme])) {
throw new Exception\InvalidArgumentException(sprintf(
'no class registered for scheme "%s"',
$scheme
));
throw new Exception\InvalidArgumentException(sprintf(
'no class registered for scheme "%s"',
$scheme
));
}
if ($scheme && isset(static::$schemeClasses[$scheme])) {
$class = static::$schemeClasses[$scheme];
$uri = new $class($uri);
if (! $uri instanceof UriInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'class "%s" registered for scheme "%s" does not implement Zend\Uri\UriInterface',
$class,
$scheme
));
}
$class = static::$schemeClasses[$scheme];
$uri = new $class($uri);
if (! $uri instanceof UriInterface) {
throw new Exception\InvalidArgumentException(sprintf(
'class "%s" registered for scheme "%s" does not implement Zend\Uri\UriInterface',
$class,
$scheme
));
}
}

return $uri;
}
}
52 changes: 26 additions & 26 deletions test/UriFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,71 +38,71 @@ public function testRegisteringNewScheme($scheme, $class)
$this->assertAttributeContains($class, 'schemeClasses', '\Zend\Uri\UriFactory');
UriFactory::unregisterScheme($scheme);
$this->assertAttributeNotContains($class, 'schemeClasses', '\Zend\Uri\UriFactory');

}

/**
* Provide the data for the RegisterNewScheme-test
*/
public function registeringNewSchemeProvider()
{
return array(
array('ssh', 'Foo\Bar\Class'),
array('ntp', 'No real class at all!!!'),
);
return array(
array('ssh', 'Foo\Bar\Class'),
array('ntp', 'No real class at all!!!'),
);
}

/**
* Test creation of new URI with an existing scheme-classd
*
* @param string $uri THe URI to create
* @param string $expectedClass The class expected
*
*
* @dataProvider createUriWithFactoryProvider
*/
public function testCreateUriWithFactory($uri, $expectedClass)
{
$class = UriFactory::factory($uri);
$this->assertInstanceof($expectedClass, $class);
$class = UriFactory::factory($uri);
$this->assertInstanceof($expectedClass, $class);
}

/**
* Providethe data for the CreateUriWithFactory-test
*
*
* @return array
*/
public function createUriWithFactoryProvider()
{
return array(
array('http://example.com', 'Zend\Uri\Http'),
array('https://example.com', 'Zend\Uri\Http'),
array('mailto://example.com', 'Zend\Uri\Mailto'),
array('file://example.com', 'Zend\Uri\File'),
);
return array(
array('http://example.com', 'Zend\Uri\Http'),
array('https://example.com', 'Zend\Uri\Http'),
array('mailto://example.com', 'Zend\Uri\Mailto'),
array('file://example.com', 'Zend\Uri\File'),
);
}

/**
* Test, that unknown Schemes will result in an exception
*
*
* @param string $uri an uri with an unknown scheme
* @expectedException Zend\Uri\Exception\InvalidArgumentException
* @dataProvider unknownSchemeThrowsExceptionProvider
*/
public function testUnknownSchemeThrowsException($uri)
{
$url = UriFactory::factory($uri);
$url = UriFactory::factory($uri);
}

/**
* Provide data to the unknownSchemeThrowsException-TEst
*
*
* @return array
*/
public function unknownSchemeThrowsExceptionProvider()
{
return array(
array('foo://bar'),
array('ssh://bar'),
);
return array(
array('foo://bar'),
array('ssh://bar'),
);
}
}

0 comments on commit f63f002

Please sign in to comment.