@@ -111,7 +111,7 @@ |
||
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
| 114 | - $commands->each(function ($command) use ($node) { |
|
| 114 | + $commands->each(function($command) use ($node) { |
|
| 115 | 115 | $class = "\\Axiom\\Rivescript\\Cortex\\Commands\\$command"; |
| 116 | 116 | $commandClass = new $class(); |
| 117 | 117 | $commandClass->parse($node); |
@@ -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,18 +76,18 @@ 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] === '{') { |
| 90 | - $key = "/\b" . preg_quote($match[3], '/') . "\b/"; |
|
| 90 | + $key = "/\b".preg_quote($match[3], '/')."\b/"; |
|
| 91 | 91 | $sub = synapse()->memory->person()->get($key) ?? "undefined"; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | if (strpos($sub, '.') > -1) { |
| 74 | 74 | $parts = explode('.', $sub); |
| 75 | 75 | if (count($parts) !== 0) { |
| 76 | - array_walk($parts, static function (&$part) { |
|
| 76 | + array_walk($parts, static function(&$part) { |
|
| 77 | 77 | $part = ucfirst(trim($part)); |
| 78 | 78 | }); |
| 79 | 79 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | $this->sourceType = $sourceType; |
| 63 | 63 | |
| 64 | 64 | if (!isset($this->allowedSources)) { |
| 65 | - throw new LogicException(get_class($this) . " must have an \"allowedSources\" property declared."); |
|
| 65 | + throw new LogicException(get_class($this)." must have an \"allowedSources\" property declared."); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $triggers = $this->determineWordCount($triggers); |
| 95 | 95 | $triggers = $this->determineTypeCount($triggers); |
| 96 | 96 | |
| 97 | - return $triggers->sort(function ($current, $previous) { |
|
| 97 | + return $triggers->sort(function($current, $previous) { |
|
| 98 | 98 | return ($current['order'] < $previous['order']) ? -1 : 1; |
| 99 | 99 | })->reverse(); |
| 100 | 100 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function determineTypeCount(Collection $triggers): Collection |
| 110 | 110 | { |
| 111 | - return $triggers->each(function ($data, $trigger) use ($triggers) { |
|
| 111 | + return $triggers->each(function($data, $trigger) use ($triggers) { |
|
| 112 | 112 | if (isset($data['type'])) { |
| 113 | 113 | switch ($data['type']) { |
| 114 | 114 | case 'atomic': |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | protected function determineWordCount(Collection $triggers): Collection |
| 142 | 142 | { |
| 143 | - return $triggers->each(function ($data, $trigger) use ($triggers) { |
|
| 143 | + return $triggers->each(function($data, $trigger) use ($triggers) { |
|
| 144 | 144 | $data['order'] = count(explode(' ', $trigger)); |
| 145 | 145 | |
| 146 | 146 | $triggers->put($trigger, $data); |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | stream_wrapper_unregister($this->name); |
| 71 | 71 | } |
| 72 | 72 | if (stream_wrapper_register($this->name, ContentStream::class) === true) { |
| 73 | - $this->stream = fopen($this->name . "://input", 'wb+'); |
|
| 73 | + $this->stream = fopen($this->name."://input", 'wb+'); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if (is_resource($this->stream) === false) { |
@@ -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) { |
@@ -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 . '$/u', $input->source(), $wildcards)) { |
|
| 61 | + if (@preg_match_all('/'.$parsedTrigger.'$/u', $input->source(), $wildcards)) { |
|
| 62 | 62 | array_shift($wildcards); |
| 63 | 63 | |
| 64 | 64 | $wildcards = Collection::make($wildcards)->flatten()->all(); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | public function process(): string |
| 75 | 75 | { |
| 76 | 76 | synapse()->brain->topic()->triggers()->each( |
| 77 | - function ($data, $trigger) { |
|
| 77 | + function($data, $trigger) { |
|
| 78 | 78 | $this->searchTriggers($trigger); |
| 79 | 79 | |
| 80 | 80 | if ($this->output !== 'Error: Response could not be determined.') { |
@@ -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 | $triggerClass = new $triggerClass($this->input); |
| 102 | 102 | |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | protected function searchTriggers2(string $trigger) |
| 163 | 163 | { |
| 164 | 164 | synapse()->triggers->each( |
| 165 | - function ($class) use ($trigger) { |
|
| 165 | + function($class) use ($trigger) { |
|
| 166 | 166 | $triggerClass = "\\Axiom\\Rivescript\\Cortex\\Triggers\\$class"; |
| 167 | 167 | $triggerClass = new $triggerClass($this->input); |
| 168 | 168 | |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | protected function parseResponse(string $response): string |
| 326 | 326 | { |
| 327 | 327 | synapse()->tags->each( |
| 328 | - function ($tag) use (&$response) { |
|
| 328 | + function($tag) use (&$response) { |
|
| 329 | 329 | $class = "\\Axiom\\Rivescript\\Cortex\\Tags\\$tag"; |
| 330 | 330 | $tagClass = new $class(); |
| 331 | 331 | |