@@ -55,7 +55,7 @@ |
||
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if (@preg_match_all('/' . $trigger . '$/ui', $input->source(), $wildcards)) { |
|
| 58 | + if (@preg_match_all('/'.$trigger.'$/ui', $input->source(), $wildcards)) { |
|
| 59 | 59 | array_shift($wildcards); |
| 60 | 60 | |
| 61 | 61 | if ($wildcards) { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | $sub = ""; |
| 68 | 68 | |
| 69 | 69 | foreach ($patterns as $index => $pattern) { |
| 70 | - $patterns[$index] = "/\b" . $pattern . "\b/i"; |
|
| 70 | + $patterns[$index] = "/\b".$pattern."\b/i"; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // TODO: Test multiple person wildcards |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | if ($match[0] === '<person>' && is_array($wildcards) === true && count($wildcards) > 0) { |
| 77 | 77 | if (count($patterns) > 0) { |
| 78 | 78 | foreach ($patterns as $index => $pattern) { |
| 79 | - $sub = preg_replace($pattern, $replacements[$index], $wildcards[0]);// ?? 'undefined'; |
|
| 79 | + $sub = preg_replace($pattern, $replacements[$index], $wildcards[0]); // ?? 'undefined'; |
|
| 80 | 80 | |
| 81 | 81 | if ($sub !== $wildcards[0]) { |
| 82 | 82 | $source = str_replace($match[0], $sub, $source); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | } else { |
| 86 | - $sub = preg_replace($patterns, $replacements, $wildcards[0], 1);// ?? 'undefined'; |
|
| 86 | + $sub = preg_replace($patterns, $replacements, $wildcards[0], 1); // ?? 'undefined'; |
|
| 87 | 87 | $source = str_replace($match[0], $sub, $source); |
| 88 | 88 | } |
| 89 | 89 | } elseif ($match[1] === '{') { |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | public function attach(Node $node): void |
| 82 | 82 | { |
| 83 | 83 | $type = $this->determineResponseType($node->source()); |
| 84 | - $queueItem = new ResponseQueueItem($node->command(), $type, 0, $this->options); |
|
| 84 | + $queueItem = new ResponseQueueItem($node->command(), $type, 0, $this->options); |
|
| 85 | 85 | $this->responses->put($node->value(), $queueItem); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | private function sortResponses(Collection $responses): Collection |
| 96 | 96 | { |
| 97 | 97 | return $responses->sort( |
| 98 | - function ($current, $previous) { |
|
| 98 | + function($current, $previous) { |
|
| 99 | 99 | return ($current->order < $previous->order) ? -1 : 1; |
| 100 | 100 | } |
| 101 | 101 | )->reverse(); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $continues = Collection::make($responses->all()); |
| 146 | 146 | $continues->each( |
| 147 | - function (ResponseQueueItem $data, $response) use (&$lastData, &$lastResponse, &$continues) { |
|
| 147 | + function(ResponseQueueItem $data, $response) use (&$lastData, &$lastResponse, &$continues) { |
|
| 148 | 148 | |
| 149 | 149 | if ($data->type === 'continue') { |
| 150 | 150 | $continues->remove($lastResponse); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | private function determineResponseOrder(Collection $responses): Collection |
| 198 | 198 | { |
| 199 | 199 | return $responses->each( |
| 200 | - function (ResponseQueueItem $data, $response) use ($responses) { |
|
| 200 | + function(ResponseQueueItem $data, $response) use ($responses) { |
|
| 201 | 201 | if (isset($data->type)) { |
| 202 | 202 | switch ($data->type) { |
| 203 | 203 | case 'condition': |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | parent::__construct(); |
| 79 | 79 | |
| 80 | - include __DIR__ . '/bootstrap.php'; |
|
| 80 | + include __DIR__.'/bootstrap.php'; |
|
| 81 | 81 | |
| 82 | 82 | synapse()->brain->setMaster($this); |
| 83 | 83 | synapse()->rivescript = $this; |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | private function registerTags(): void |
| 94 | 94 | { |
| 95 | 95 | synapse()->tags->each( |
| 96 | - function ($tag) { |
|
| 96 | + function($tag) { |
|
| 97 | 97 | $class = "\\Axiom\\Rivescript\\Cortex\\Tags\\$tag"; |
| 98 | 98 | $tagInstance = new $class(); |
| 99 | 99 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | protected function searchTriggers(string $trigger): void |
| 79 | 79 | { |
| 80 | 80 | synapse()->triggers->each( |
| 81 | - function ($class) use ($trigger) { |
|
| 81 | + function($class) use ($trigger) { |
|
| 82 | 82 | $triggerClass = "\\Axiom\\Rivescript\\Cortex\\Triggers\\$class"; |
| 83 | 83 | $triggerClass = new $triggerClass(synapse()->input); |
| 84 | 84 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | protected function parseResponse(string $response): string |
| 155 | 155 | { |
| 156 | 156 | synapse()->tags->each( |
| 157 | - function ($tag) use (&$response) { |
|
| 157 | + function($tag) use (&$response) { |
|
| 158 | 158 | $class = "\\Axiom\\Rivescript\\Cortex\\Tags\\$tag"; |
| 159 | 159 | $tagClass = new $class(); |
| 160 | 160 | |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | protected function parseTags(string $trigger, Input $input): string |
| 44 | 44 | { |
| 45 | - synapse()->tags->each(function ($tag) use (&$trigger, $input) { |
|
| 45 | + synapse()->tags->each(function($tag) use (&$trigger, $input) { |
|
| 46 | 46 | $class = "\\Axiom\\Rivescript\\Cortex\\Tags\\$tag"; |
| 47 | 47 | $tagClass = new $class("trigger"); |
| 48 | 48 | |
@@ -52,13 +52,13 @@ |
||
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | 54 | foreach ($wildcards as $pattern => $replacement) { |
| 55 | - $parsedTrigger = preg_replace($pattern, '(' . $replacement . ')', $trigger); |
|
| 55 | + $parsedTrigger = preg_replace($pattern, '('.$replacement.')', $trigger); |
|
| 56 | 56 | |
| 57 | 57 | if ($parsedTrigger === $trigger) { |
| 58 | 58 | continue; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if (@preg_match_all('/' . $parsedTrigger . '$/iu', $input->source(), $wildcards)) { |
|
| 61 | + if (@preg_match_all('/'.$parsedTrigger.'$/iu', $input->source(), $wildcards)) { |
|
| 62 | 62 | array_shift($wildcards); |
| 63 | 63 | |
| 64 | 64 | $wildcards = Collection::make($wildcards)->flatten()->all(); |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | $sentences [] = $tmp; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $result = array_filter($sentences, static function (string $sentence) use ($input) { |
|
| 94 | + $result = array_filter($sentences, static function(string $sentence) use ($input) { |
|
| 95 | 95 | return (strtolower($sentence) === strtolower($input->source())); |
| 96 | 96 | }); |
| 97 | 97 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | public function execute(InputInterface $input, OutputInterface $output): int |
| 76 | 76 | { |
| 77 | 77 | try { |
| 78 | - $this->rivescript->onSay = function (string $msg, int $verbosity) use ($output) { |
|
| 78 | + $this->rivescript->onSay = function(string $msg, int $verbosity) use ($output) { |
|
| 79 | 79 | $output->writeln("Say: {$msg}", $verbosity); |
| 80 | 80 | }; |
| 81 | 81 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $output->writeln('RiveScript Interpreter (PHP) -- Interactive Console v2.0'); |
| 91 | 91 | $output->writeln('--------------------------------------------------------'); |
| 92 | 92 | $output->writeln('RiveScript Version: 2.0'); |
| 93 | - $output->writeln('Currently Loaded Source: ' . $loadedSource); |
|
| 93 | + $output->writeln('Currently Loaded Source: '.$loadedSource); |
|
| 94 | 94 | $output->writeln(''); |
| 95 | 95 | $output->writeln('You are now chatting with a RiveScript bot. Type a message and press Return'); |
| 96 | 96 | $output->writeln('to send it. When finished, type "/quit" to exit the interactive console.'); |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | $reply = $this->rivescript->reply($message); |
| 180 | 180 | $response = "<info>{$reply}</info>"; |
| 181 | 181 | |
| 182 | - $output->writeln($bot . $response); |
|
| 182 | + $output->writeln($bot.$response); |
|
| 183 | 183 | |
| 184 | 184 | $this->waitForUserInput($input, $output); |
| 185 | 185 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | if (is_dir($info)) { |
| 197 | 197 | $directory = realpath($info); |
| 198 | 198 | $files = []; |
| 199 | - $brains = glob($directory . '/*.rive'); |
|
| 199 | + $brains = glob($directory.'/*.rive'); |
|
| 200 | 200 | |
| 201 | 201 | foreach ($brains as $brain) { |
| 202 | 202 | $files[] = $brain; |