protected function getCodeFromFile()
    {
        $file = $this->getFile();

        $code = '';

        // Next, we will just loop through the lines of the file until we get to the end
        // of the Closure. Then, we will return the complete contents of this Closure
        // so it can be serialized with these variables and stored for later usage.
        while ($file->key() < $this->reflection->getEndLine()) {
            $code .= $file->current();
            $file->next();
        }

        preg_match('/function\s*\(/', $code, $matches, PREG_OFFSET_CAPTURE);
        $begin = isset($matches[0][1]) ? $matches[0][1] : 0;

        return substr($code, $begin, strrpos($code, '}') - $begin + 1);
    }