added comments and renamed short method to url generators

main
msquare 6 years ago
parent 86b2937078
commit 9496e35711

@ -33,7 +33,7 @@ function User_tshirt_score($user) {
WHERE `User`.`UID` = ? WHERE `User`.`UID` = ?
AND `Shifts`.`end` < ? AND `Shifts`.`end` < ?
GROUP BY `User`.`UID` GROUP BY `User`.`UID`
',[ ', [
$user['UID'], $user['UID'],
time() time()
]); ]);

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

@ -14,7 +14,7 @@ class UrlGenerator implements UrlGeneratorInterface
* @param array $parameters * @param array $parameters
* @return string url in the form [app url]/[path]?[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, '/'); $path = '/' . ltrim($path, '/');
$request = app('request'); $request = app('request');

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

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

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

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

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

Loading…
Cancel
Save