@@ -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': |
@@ -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(); |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | $sentences [] = trim($tmp); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $result = array_filter($sentences, static function (string $sentence) use ($input) { |
|
| 93 | + $result = array_filter($sentences, static function(string $sentence) use ($input) { |
|
| 94 | 94 | return (strtolower($sentence) === strtolower($input->source())); |
| 95 | 95 | }); |
| 96 | 96 | |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | $sentences [] = trim($tmp); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $result = array_filter($sentences, static function (string $sentence) use ($input) { |
|
| 93 | + $result = array_filter($sentences, static function(string $sentence) use ($input) { |
|
| 94 | 94 | return (strtolower($sentence) === strtolower($input->source())); |
| 95 | 95 | }); |
| 96 | 96 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | if (count($set) > 0) { |
| 91 | 91 | if ($match[1] === '(') { |
| 92 | 92 | foreach ($set as $setIndex => $item) { |
| 93 | - $set[$setIndex] = $this->signatures['alternation'] . $item; |
|
| 93 | + $set[$setIndex] = $this->signatures['alternation'].$item; |
|
| 94 | 94 | $set[$setIndex] = str_replace(" ", $this->signatures['alternation'], $set[$setIndex]); |
| 95 | 95 | } |
| 96 | 96 | $triggerString = str_replace($match[0], "{{$index}}", $triggerString); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $tmp = str_replace("{{$index}}", $string, $tmp); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - $tmp = str_replace([$this->signatures['optional'] . " ", $this->signatures['optional']], "", $tmp); |
|
| 124 | + $tmp = str_replace([$this->signatures['optional']." ", $this->signatures['optional']], "", $tmp); |
|
| 125 | 125 | $tmp = trim($tmp); |
| 126 | 126 | |
| 127 | 127 | $sentences [] = $tmp; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $signature = $this->signatures['alternation']; |
| 131 | 131 | $cmp = [$this, 'isMatchesWithoutSignature']; |
| 132 | 132 | |
| 133 | - $result = array_filter($sentences, static function (string $sentence) use ($input, $signature, $cmp) { |
|
| 133 | + $result = array_filter($sentences, static function(string $sentence) use ($input, $signature, $cmp) { |
|
| 134 | 134 | if (strpos($sentence, $signature) > -1) { |
| 135 | 135 | return $cmp(strtolower($sentence), strtolower($input->source())); |
| 136 | 136 | } |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | public function parse(string $source, SourceInput $input): string |
| 55 | 55 | { |
| 56 | 56 | if (!$this->sourceAllowed()) { |
| 57 | - return $source; |
|
| 57 | + return $source; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if ($this->hasMatches($source)) { |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | protected function searchTriggers(string $trigger): void |
| 97 | 97 | { |
| 98 | 98 | synapse()->triggers->each( |
| 99 | - function ($class) use ($trigger) { |
|
| 99 | + function($class) use ($trigger) { |
|
| 100 | 100 | $triggerClass = "\\Axiom\\Rivescript\\Cortex\\Triggers\\$class"; |
| 101 | 101 | $triggerInstance = new $triggerClass(synapse()->input); |
| 102 | 102 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | protected function parseResponse(string $response): string |
| 189 | 189 | { |
| 190 | 190 | synapse()->tags->each( |
| 191 | - function ($tag) use (&$response) { |
|
| 191 | + function($tag) use (&$response) { |
|
| 192 | 192 | $class = "\\Axiom\\Rivescript\\Cortex\\Tags\\$tag"; |
| 193 | 193 | $tagClass = new $class(); |
| 194 | 194 | |