Skip to content

Commit

Permalink
Rename Route::parseExtensions() to Route::extensions()
Browse files Browse the repository at this point in the history
Having the same method names across RouteBuilder, and Route make it
easier to remember which method is correct. Additionally, the
RouteCollection will also be getting an extensions method.
  • Loading branch information
markstory committed Aug 22, 2014
1 parent 817cc77 commit c89dc17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/Routing/Route/Route.php
Expand Up @@ -111,13 +111,16 @@ public function __construct($template, $defaults = [], array $options = []) {
}

/**
* Sets the supported extensions for this route.
* Get/Set the supported extensions for this route.
*
* @param array $extensions The extensions to set.
* @return void
* @param null|array $extensions The extensions to set. Use null to get.
* @return array|void The extensions or null.
*/
public function parseExtensions(array $extensions) {
$this->_extensions = $extensions;
public function extensions($extensions = null) {
if ($extensions === null) {
return $this->_extensions;
}
$this->_extensions = (array)$extensions;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Routing/Route/RouteTest.php
Expand Up @@ -105,7 +105,7 @@ public function testRouteParsingWithExtensions() {
$result = $route->parse('/posts/index.pdf');
$this->assertFalse(isset($result['_ext']));

$route->parseExtensions(array('pdf', 'json', 'xml'));
$route->extensions(array('pdf', 'json', 'xml'));
$result = $route->parse('/posts/index.pdf');
$this->assertEquals('pdf', $result['_ext']);

Expand Down

0 comments on commit c89dc17

Please sign in to comment.