@@ -66,7 +66,7 @@ |
||
| 66 | 66 | $data = []; |
| 67 | 67 | $valid = preg_match("/(?P<count>[0-9]+)?d(?P<size>[0-9]+)/i", $part, $data); |
| 68 | 68 | if (!$valid) { |
| 69 | - throw new UncreatableDiceException("Problem creating dice from incorrectly formated data: " + $part); |
|
| 69 | + throw new UncreatableDiceException("Problem creating dice from incorrectly formated data: " +$part); |
|
| 70 | 70 | } |
| 71 | 71 | if (!$data["count"]) { |
| 72 | 72 | $data["count"] = 1; |
@@ -8,11 +8,11 @@ |
||
| 8 | 8 | use MeadSteve\DiceApi\RequestHandler\DiceRequestHandler; |
| 9 | 9 | use Predis\Client; |
| 10 | 10 | |
| 11 | -require __DIR__ . "/../vendor/autoload.php"; |
|
| 11 | +require __DIR__."/../vendor/autoload.php"; |
|
| 12 | 12 | |
| 13 | 13 | $diceGenerator = new DiceGenerator(); |
| 14 | 14 | |
| 15 | -$rendererFactory = new RendererFactory('http://' . $_SERVER['HTTP_HOST']); |
|
| 15 | +$rendererFactory = new RendererFactory('http://'.$_SERVER['HTTP_HOST']); |
|
| 16 | 16 | |
| 17 | 17 | if (isset($_ENV['REDIS_URL'])) { |
| 18 | 18 | $redis = new Client( |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | $this->diceCounter->count($dice); |
| 43 | 43 | } catch (UncreatableDiceException $creationError) { |
| 44 | 44 | $diceResponse = $diceResponse->withStatus(400) |
| 45 | - ->write("Unable to roll dice: " . $creationError->getMessage()); |
|
| 45 | + ->write("Unable to roll dice: ".$creationError->getMessage()); |
|
| 46 | 46 | } catch (UnrenderableDiceException $renderError) { |
| 47 | 47 | $diceResponse = $diceResponse->withStatus(400) |
| 48 | - ->write("Unable to render request: " . $renderError->getMessage()); |
|
| 48 | + ->write("Unable to render request: ".$renderError->getMessage()); |
|
| 49 | 49 | } |
| 50 | 50 | return $diceResponse; |
| 51 | 51 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | ->withHeader("Content-Type", $renderer->contentType()); |
| 61 | 61 | } catch (UnknownRendererException $error) { |
| 62 | 62 | $responseWithOutput = $response->withStatus(406); |
| 63 | - $responseWithOutput->write("Not sure how to respond with: " . $requestedContentType); |
|
| 63 | + $responseWithOutput->write("Not sure how to respond with: ".$requestedContentType); |
|
| 64 | 64 | } |
| 65 | 65 | return $responseWithOutput; |
| 66 | 66 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | { |
| 70 | 70 | $rolledValue = $request->getHeader('totally-legit')[0]; |
| 71 | 71 | return array_map( |
| 72 | - function (Dice $dice) use ($rolledValue) { |
|
| 72 | + function(Dice $dice) use ($rolledValue) { |
|
| 73 | 73 | return new TotallyLegit($dice, (int) $rolledValue); |
| 74 | 74 | }, |
| 75 | 75 | $dice |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function roll() |
| 22 | 22 | { |
| 23 | - if (! function_exists('random_int')) { |
|
| 23 | + if (!function_exists('random_int')) { |
|
| 24 | 24 | return mt_rand(1, $this->size); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function index(Request $request, Response $response) |
| 27 | 27 | { |
| 28 | - $indexFilePath = __DIR__ . "/generated-index.html"; |
|
| 28 | + $indexFilePath = __DIR__."/generated-index.html"; |
|
| 29 | 29 | if (!file_exists($indexFilePath)) { |
| 30 | 30 | $converter = new CommonMarkConverter(); |
| 31 | - $indexBody = $converter->convertToHtml(file_get_contents(__DIR__ . "/../README.md")); |
|
| 32 | - $indexContent = file_get_contents(__DIR__ . "/../www/templates/index.html"); |
|
| 31 | + $indexBody = $converter->convertToHtml(file_get_contents(__DIR__."/../README.md")); |
|
| 32 | + $indexContent = file_get_contents(__DIR__."/../www/templates/index.html"); |
|
| 33 | 33 | $indexContent = str_replace("{{body}}", $indexBody, $indexContent); |
| 34 | 34 | file_put_contents($indexFilePath, $indexContent); |
| 35 | 35 | $response->write($indexContent); |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | $this->get("/dice-stats", [$this, 'diceStats']); |
| 54 | 54 | $this->get("{dice:(?:/[0-9]*[dD][0-9]+)+/?}", [$this->diceRequestHandler, 'getDice']); |
| 55 | 55 | |
| 56 | - $this->get("/html{dice:(?:/[0-9]*[dD][0-9]+)+/?}", function (Request $request, $response, $args) { |
|
| 56 | + $this->get("/html{dice:(?:/[0-9]*[dD][0-9]+)+/?}", function(Request $request, $response, $args) { |
|
| 57 | 57 | return $this->diceRequestHandler->getDice( |
| 58 | 58 | $request->withHeader('accept', 'text/html'), |
| 59 | 59 | $response, |
| 60 | 60 | $args |
| 61 | 61 | ); |
| 62 | 62 | }); |
| 63 | - $this->get("/json{dice:(?:/[0-9]*[dD][0-9]+)+/?}", function (Request $request, $response, $args) { |
|
| 63 | + $this->get("/json{dice:(?:/[0-9]*[dD][0-9]+)+/?}", function(Request $request, $response, $args) { |
|
| 64 | 64 | return $this->diceRequestHandler->getDice( |
| 65 | 65 | $request->withHeader('accept', 'application/json'), |
| 66 | 66 | $response, |
@@ -35,6 +35,6 @@ |
||
| 35 | 35 | } |
| 36 | 36 | $roll = $dice->roll(); |
| 37 | 37 | $url = "{$this->urlRoot}/images/poorly-drawn/d{$size}/{$roll}.png"; |
| 38 | - return '<img src="' . $url . '" />'; |
|
| 38 | + return '<img src="'.$url.'" />'; |
|
| 39 | 39 | } |
| 40 | 40 | } |
@@ -26,10 +26,10 @@ |
||
| 26 | 26 | |
| 27 | 27 | private function diceAsAssocArrays(array $diceCollection) |
| 28 | 28 | { |
| 29 | - return array_map(function (Dice $dice) { |
|
| 29 | + return array_map(function(Dice $dice) { |
|
| 30 | 30 | return [ |
| 31 | 31 | "value" => $dice->roll(), |
| 32 | - "size" => "d" . $dice->size() |
|
| 32 | + "size" => "d".$dice->size() |
|
| 33 | 33 | ]; |
| 34 | 34 | }, $diceCollection); |
| 35 | 35 | } |