Kahlan\Jit\TokenStream::load PHP Method

load() public method

Load the stream using a string (destroy previous loaded tokens)
public load ( string $source, $options = [] )
$source string Source code
    public function load($source, $options = [])
    {
        $defaults = ['wrap' => false];
        $options += $defaults;
        $wrap = $options['wrap'];
        if ($wrap) {
            $source = "<?php {$source}?>";
        }
        $this->_data = [];
        $this->_current = 0;
        foreach (token_get_all($source) as $token) {
            $this->_data[] = is_array($token) ? $token : [$token, $token, null];
        }
        if ($wrap) {
            $this->_data = array_slice($this->_data, 1, count($this->_data) - 2);
        }
        $this->_count = count($this->_data);
    }