added comments and renamed short method to url generators

This commit is contained in:
msquare 2018-08-06 12:57:48 +02:00
parent 86b2937078
commit 9496e35711
8 changed files with 9 additions and 9 deletions

View File

@ -14,7 +14,7 @@ class LegacyUrlGenerator extends UrlGenerator
* @param array $parameters
* @return string urls in the form <app url>/index.php?p=<path>&<parameters>
*/
public function link_to($path, $parameters = [])
public function linkTo($path, $parameters = [])
{
$page = ltrim($path, '/');
if (!empty($page)) {
@ -22,7 +22,7 @@ class LegacyUrlGenerator extends UrlGenerator
$parameters = array_merge(['p' => $page], $parameters);
}
$uri = parent::link_to('index.php', $parameters);
$uri = parent::linkTo('index.php', $parameters);
$uri = preg_replace('~(/index\.php)+~', '/index.php', $uri);
return $uri;

View File

@ -14,7 +14,7 @@ class UrlGenerator implements UrlGeneratorInterface
* @param array $parameters
* @return string url in the form [app url]/[path]?[parameters]
*/
public function link_to($path, $parameters = [])
public function linkTo($path, $parameters = [])
{
$path = '/' . ltrim($path, '/');
$request = app('request');

View File

@ -12,5 +12,5 @@ interface UrlGeneratorInterface
* @param array $parameters
* @return string
*/
public function link_to($path, $parameters = []);
public function linkTo($path, $parameters = []);
}

View File

@ -124,7 +124,7 @@ function url($path = null, $parameters = [])
return $urlGenerator;
}
return $urlGenerator->link_to($path, $parameters);
return $urlGenerator->linkTo($path, $parameters);
}
/**

View File

@ -177,7 +177,7 @@ class HelpersTest extends TestCase
$this->assertEquals($urlGeneratorMock, url());
$urlGeneratorMock->expects($this->once())
->method('link_to')
->method('linkTo')
->with('foo/bar', ['param' => 'value'])
->willReturn('http://lorem.ipsum/foo/bar?param=value');

View File

@ -48,7 +48,7 @@ class LegacyUrlGeneratorTest extends TestCase
$urlGenerator = new LegacyUrlGenerator();
$this->assertInstanceOf(UrlGeneratorInterface::class, $urlGenerator);
$url = $urlGenerator->link_to($urlToPath, $arguments);
$url = $urlGenerator->linkTo($urlToPath, $arguments);
$this->assertEquals($expectedUrl, $url);
}
}

View File

@ -48,7 +48,7 @@ class UrlGeneratorTest extends TestCase
$urlGenerator = new UrlGenerator();
$this->assertInstanceOf(UrlGeneratorInterface::class, $urlGenerator);
$url = $urlGenerator->link_to($urlToPath, $arguments);
$url = $urlGenerator->linkTo($urlToPath, $arguments);
$this->assertEquals($expectedUrl, $url);
}
}