src/Cortex/Brain.php
public function teach($file)
    {
        $commands   = synapse()->commands;
        $file       = new SplFileObject($file);
        $lineNumber = 0;

        while (! $file->eof()) {
            $currentCommand = null;
            $node           = new Node($file->fgets(), $lineNumber++);

            if ($node->isInterrupted() or $node->isComment()) {
                continue;
            }

            $commands->each(function ($command) use ($node, $currentCommand) {
                $class = "\\Axiom\\Rivescript\\Cortex\\Commands\\$command";
                $commandClass = new $class();

                $result = $commandClass->parse($node, $currentCommand);

                if (isset($result['command'])) {
                    $currentCommand = $result['command'];

                    return false;
                }
            });
        }
    }
public function teach($file)
    {
        $commands   = synapse()->commands;
        $file       = new SplFileObject($file);
        $lineNumber = 0;

        while (! $file->eof()) {
            $currentCommand = null;
            $node           = new Node($file->fgets(), $lineNumber++);

            if ($node->isInterrupted() or $node->isComment()) {
                continue;
            }

            $commands->each(function ($command) use ($node, $currentCommand) {
                $class = "\\Axiom\\Rivescript\\Cortex\\Commands\\$command";
                $commandClass = new $class();

                $result = $commandClass->parse($node, $currentCommand);

                if (isset($result['command'])) {
                    $currentCommand = $result['command'];

                    return false;
                }
            });
        }
    }
public function teach ( $ file ) { $ commands = synapse ( ) -> commands ; $ file = new SplFileObject ( $ file ) ; $ lineNumber = 0 ; while ( ! $ file -> eof ( ) ) { $ currentCommand = null ; $ node = new Node ( $ file -> fgets ( ) , $ lineNumber ++ ) ; if ( $ node -> isInterrupted ( ) or $ node -> isComment ( ) ) { continue ; } $ commands -> each ( function ( $ command ) use ( $ node , $ currentCommand ) { $ class = "\\Axiom\\Rivescript\\Cortex\\Commands\\$command" ; $ commandClass = new $ class ( ) ; $ result = $ commandClass -> parse ( $ node , $ currentCommand ) ; if ( isset ( $ result [ 'command' ] ) ) { $ currentCommand = $ result [ 'command' ] ; return false ; } } ) ; } }
Teach the brain contents of a new file source.

@param string $file
Teach the brain contents of a new file source .