@@ -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) { |
@@ -69,21 +69,21 @@ |
||
| 69 | 69 | $sub = ""; |
| 70 | 70 | |
| 71 | 71 | foreach ($patterns as $index => $pattern) { |
| 72 | - $patterns[$index] = "/\b" . $pattern . "\b/i"; |
|
| 72 | + $patterns[$index] = "/\b".$pattern."\b/i"; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // TODO: Test multiple person wildcards |
| 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] === '{') { |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | public function parse() |
| 39 | 39 | { |
| 40 | 40 | if ($this->responseQueueItem()->getCommand() === '@') { |
| 41 | - return $this->source(); |
|
| 41 | + return $this->source(); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | return false; |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - // $sub = str_replace(["<", ">"], ["<", ">"], $sub); |
|
| 89 | + // $sub = str_replace(["<", ">"], ["<", ">"], $sub); |
|
| 90 | 90 | |
| 91 | 91 | $source = str_replace($match[0], $sub, $source); |
| 92 | 92 | } |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | if (strpos($sub, '.') > -1) { |
| 76 | 76 | $parts = explode('.', $sub); |
| 77 | 77 | if (count($parts) !== 0) { |
| 78 | - array_walk($parts, static function (&$part) { |
|
| 78 | + array_walk($parts, static function(&$part) { |
|
| 79 | 79 | $part = ucfirst(trim($part)); |
| 80 | 80 | }); |
| 81 | 81 | } |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | /** |
| 83 | 83 | * Find the match |
| 84 | 84 | */ |
| 85 | - $regex = "(" . implode('|', $array) . ")"; |
|
| 86 | - if (@preg_match_all('/' . $regex . '/ui', $input->source(), $wildcards)) { |
|
| 85 | + $regex = "(".implode('|', $array).")"; |
|
| 86 | + if (@preg_match_all('/'.$regex.'/ui', $input->source(), $wildcards)) { |
|
| 87 | 87 | array_shift($wildcards); |
| 88 | 88 | |
| 89 | 89 | if ($wildcards) { |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * Find the match |
| 101 | 101 | */ |
| 102 | - $regex = "(?:" . implode('|', $array) . ")"; |
|
| 102 | + $regex = "(?:".implode('|', $array).")"; |
|
| 103 | 103 | |
| 104 | - if (@preg_match_all('/' . $regex . '/ui', $source, $results)) { |
|
| 104 | + if (@preg_match_all('/'.$regex.'/ui', $source, $results)) { |
|
| 105 | 105 | foreach ($results as $result) { |
| 106 | 106 | $source = str_replace("@{$name}", $result[0], $source); |
| 107 | 107 | } |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | 265 | public function warn(string $message, |
| 266 | - array $args = [], |
|
| 267 | - int $verbosity = Rivescript::VERBOSITY_DEBUG): void |
|
| 266 | + array $args = [], |
|
| 267 | + int $verbosity = Rivescript::VERBOSITY_DEBUG): void |
|
| 268 | 268 | { |
| 269 | 269 | $message = "[WARNING]: " . $this->formatString($message, $args); |
| 270 | 270 | |
@@ -281,8 +281,8 @@ discard block |
||
| 281 | 281 | * @return void |
| 282 | 282 | */ |
| 283 | 283 | public function debug(string $message, |
| 284 | - array $args = [], |
|
| 285 | - int $verbosity = Rivescript::VERBOSITY_NORMAL): void |
|
| 284 | + array $args = [], |
|
| 285 | + int $verbosity = Rivescript::VERBOSITY_NORMAL): void |
|
| 286 | 286 | { |
| 287 | 287 | $message = "[DEBUG]: " . $this->formatString($message, $args); |
| 288 | 288 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | { |
| 100 | 100 | parent::__construct(); |
| 101 | 101 | |
| 102 | - include __DIR__ . '/bootstrap.php'; |
|
| 102 | + include __DIR__.'/bootstrap.php'; |
|
| 103 | 103 | |
| 104 | 104 | $options; |
| 105 | 105 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | private function registerTags(): void |
| 119 | 119 | { |
| 120 | 120 | synapse()->tags->each( |
| 121 | - function ($tag) { |
|
| 121 | + function($tag) { |
|
| 122 | 122 | $class = "\\Axiom\\Rivescript\\Cortex\\Tags\\$tag"; |
| 123 | 123 | $tagInstance = new $class(); |
| 124 | 124 | |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | array $args = [], |
| 267 | 267 | int $verbosity = Rivescript::VERBOSITY_DEBUG): void |
| 268 | 268 | { |
| 269 | - $message = "[WARNING]: " . $this->formatString($message, $args); |
|
| 269 | + $message = "[WARNING]: ".$this->formatString($message, $args); |
|
| 270 | 270 | |
| 271 | 271 | $this->emit(Event::DEBUG_WARNING, $message); |
| 272 | 272 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | array $args = [], |
| 285 | 285 | int $verbosity = Rivescript::VERBOSITY_NORMAL): void |
| 286 | 286 | { |
| 287 | - $message = "[DEBUG]: " . $this->formatString($message, $args); |
|
| 287 | + $message = "[DEBUG]: ".$this->formatString($message, $args); |
|
| 288 | 288 | |
| 289 | 289 | $this->emit(EVENT::DEBUG, $message); |
| 290 | 290 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | $rivescript->stream($script); |
| 26 | 26 | |
| 27 | 27 | $rivescript->on(Event::DEBUG, 'onDebug') |
| 28 | - ->on(Event::DEBUG_VERBOSE, 'onVerbose'); |
|
| 28 | + ->on(Event::DEBUG_VERBOSE, 'onVerbose'); |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | echo $rivescript->reply("hi bot"); |
| 32 | 32 | \ No newline at end of file |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | use Axiom\Rivescript\Events\Event; |
| 5 | 5 | use Axiom\Rivescript\Rivescript; |
| 6 | 6 | |
| 7 | -$script =<<<EOF |
|
| 7 | +$script = <<<EOF |
|
| 8 | 8 | + hi bot |
| 9 | 9 | - hello human |
| 10 | 10 | EOF; |
@@ -40,9 +40,9 @@ |
||
| 40 | 40 | public function parse(Node $node): void |
| 41 | 41 | { |
| 42 | 42 | $types = [ |
| 43 | - '-', '*', |
|
| 44 | - '^', '@', |
|
| 45 | - '%' |
|
| 43 | + '-', '*', |
|
| 44 | + '^', '@', |
|
| 45 | + '%' |
|
| 46 | 46 | ]; |
| 47 | 47 | |
| 48 | 48 | if (in_array($node->command(), $types) === true) { |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | $key = -1; |
| 57 | 57 | foreach (synapse()->brain->topic($topic)->triggers() as $index => $info) { |
| 58 | 58 | if ($info->getText() === $string) { |
| 59 | - $trigger= $info; |
|
| 59 | + $trigger = $info; |
|
| 60 | 60 | $key = $index; |
| 61 | 61 | break; |
| 62 | 62 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | $triggers = $this->determineWordCount($triggers); |
| 103 | 103 | $triggers = $this->determineTypeCount($triggers); |
| 104 | 104 | |
| 105 | - return $triggers->sort(function ($current, $previous) { |
|
| 105 | + return $triggers->sort(function($current, $previous) { |
|
| 106 | 106 | return ($current->getOrder() < $previous->getOrder()) ? -1 : 1; |
| 107 | 107 | })->reverse(); |
| 108 | 108 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | protected function determineTypeCount(Collection $triggers): Collection |
| 118 | 118 | { |
| 119 | - return $triggers->each(function (&$trigger) use ($triggers) { |
|
| 119 | + return $triggers->each(function(&$trigger) use ($triggers) { |
|
| 120 | 120 | |
| 121 | 121 | $order = $trigger->getOrder(); |
| 122 | 122 | $type = $trigger->getType(); |