Get the code from file.

@since 3.0.0

@return void
164403
protected function getPreviewCode()
    {
        $file = file($this->stack['file']);
        $line = $this->stack['line'];
        $_line = $line - 1;
        if ($_line - 5 >= 0) {
            $start = $_line - 5;
            $end = $_line + 5;
        } else {
            $start = $_line;
            $end = $line;
        }
        for ($i = $start; $i <= $end; $i++) {
            if (!isset($file[$i])) {
                break;
            }
            $text = trim($file[$i]);
            if ($i === $_line) {
                $this->stack['previewCode'] .=
                    "<span style='background:red' class='line'>".($i + 1).'</span>'.
                    "<span style='background:red'>".$text.'</span><br>';
                continue;
            }
            $this->stack['previewCode'] .=
                "<span class='line'>".($i + 1).'</span>'.
                '<span>'.$text.'</span><br>';
        }
    }
608604
private static function _load_file() {
		$t_array = file( __DIR__ . '/../../data/domains.txt' );
		$t_result_array = array();

		foreach ( $t_array as $t_line ) {
			$t_entry = trim( $t_line );
			if ( empty( $t_entry ) ) {
				continue;
			}

			# Exclude commented lines
			if ( strpos( $t_entry, '#' ) === 0 ) {
				continue;
			}

			$t_domain = strtolower( $t_entry );
			$t_result_array[$t_domain] = true;
		}

		return $t_result_array;
	}
887535
public function fixCode() {
    $command = "'{$this->bin}/phpcbf'";
    $task = $this->taskExecStack()
      ->dir($this->bltRoot)
      ->exec($command);
    $result = $task->run();

    return $result->getExitCode();
  }
1223178
public function getOrganizationCode()
    {
        if (! $this->_orgCode) {
            $this->_orgCode = $this->currentOrganization->getCode();
            if (! $this->_orgCode) {
                $this->_orgCode = \MUtil_File::cleanupName($this->currentOrganization->getName());
            }

        }

        return $this->_orgCode;
    }
745255
public function getFile()
    {
        $key = $this->getKey();

        $tags = $this->getTags();

        if (!$this->cache->has($key, $tags)) {
            $this->loadFile();
        }

        return simplexml_load_string($this->cache->get($key, $tags));
    }
979231
private function codeToMessage($code) {
        // get the error message belong to the given code
        switch ($code) {
            case \Th\FileDownloader::FILE_WRONG_MIME:
                $message = "File is of the wrong MIME type";
                break;
            case \Th\FileDownloader::FILE_WRONG_EXTENSION:
                $message = "File is of the wrong extension";
                break;
            case \Th\FileDownloader::INVALID_DOWNLOAD_DIR:
                $message = "User set download directory does not exist";
                break;
            default:
                $message = "Unknown download error";
                break;
        }

        // done, return the error message
        return $message;
    }
33965
protected function getPreviewCode()
    {
        $file = file(self::$stack['file']);
        $line = self::$stack['line'];

        $start = ($line - 5 >= 0) ? $line - 5 : $line - 1;
        $end = ($line - 5 >= 0) ? $line + 4 : $line + 8;

        for ($i = $start; $i < $end; $i++) {
            if (! isset($file[$i])) {
                continue;
            }

            $text = trim($file[$i]);

            if ($i == $line - 1) {
                self::$stack['preview'] .=
                    "<span class='jst-line'>" . ($i + 1) . '</span>' .
                    "<span class='jst-mark text'>" . $text . '</span><br>';
                continue;
            }

            self::$stack['preview'] .=
                "<span class='jst-line'>" . ($i + 1) . '</span>' .
                "<span class='text'>" . $text . '</span><br>';
        }
    }
847347
private function getOutputs() : string
    {
        ob_start();
        extract($this->data);
        require $this->file;
        $contents = ob_get_contents();
        ob_end_clean();

        return $contents;
    }
416019
public function sniffCode() {
    $task = $this->taskExecStack()
      ->dir($this->bltRoot)
      ->exec("{$this->bin}/phpcs")
      ->exec("composer validate");
    $result = $task->run();

    return $result->getExitCode();
  }
1191342
public function toString()
    {
        if (!$this->getCommand()->getExecuted() && !$this->execute()) {
            return false;
        }
        return file_get_contents($this->getTmpFile()->getFileName());
    }
234504
protected function fileContents() {
    // File contents are built up.
    $file_contents = array_merge(
      $this->file_header(),
      $this->code_header(),
      $this->code_body(),
      array(
        $this->code_footer(),
      )
    );

    return $file_contents;
  }
1149480
public function getContent()
    {
        if (null === $this->content && $this->fromGlobal) {
            $this->content = file_get_contents('php://input');
        }
        return $this->content;
    }
183122
protected function parseCode()
    {
        $brace_level      = 0;
        $parsed_code      = '';
        $parsing_complete = false;

        // Parse the code looking for the end of the function
        /** @var $token \FunctionParser\Token */
        foreach ($this->tokenizer as $token)
        {
            /***********************************************************************************************************
             * AFTER PARSING
             *
             * After the parsing is complete, we need to make sure there are no other T_FUNCTION tokens found, which
             * would indicate a possible ambiguity in the function code we retrieved. This should only happen in
             * situations where the code is minified or poorly formatted.
             */
            if ($parsing_complete)
            {
                if ($token->is(T_FUNCTION))
                {
                    throw new \RuntimeException('Cannot parse the function; multiple, non-nested functions were defined'
                        . ' in the code block containing the desired function.');
                }
                else
                {
                    continue;
                }
            }

            /***********************************************************************************************************
             * WHILE PARSING
             *
             * Scan through the tokens (while keeping track of braces) and reconstruct the code from the parsed tokens.
             */

            // Keep track of opening and closing braces
            if ($token->isOpeningBrace())
            {
                $brace_level++;
            }
            elseif ($token->isClosingBrace())
            {
                $brace_level--;

                // Once we reach the function's closing brace, mark as complete
                if ($brace_level === 0)
                {
                    $parsing_complete = true;
                }
            }

            // Reconstruct the code token by token
            $parsed_code .= $token->code;
        }

        /*
         * If all tokens have been looked at and the closing brace was not found, then there is a
         * problem with the code defining the Closure. This should probably never happen, but just
         * in case...
         */
        if (!$parsing_complete)
        {
            // @codeCoverageIgnoreStart
            throw new \RuntimeException('Cannot parse the function because the code appeared to be invalid.');
            // @codeCoverageIgnoreEnd
        }

        return $parsed_code;
    }
1304168
public function read()
    {
        $args = array_merge(
            [$this->filename],
            [false, null],
            func_get_args()
        );

        return file_get_contents(...$args);
    }
896032
public function getReasonCode()
    {
        $code = null;

        if (isset($this->data['messages'])) {
            // In case of a successful transaction, a "messages" element is present
            $code = (string)$this->data['messages']['message']['code'];
        }

        return $code;
    }
285736
protected function OnCode()
    {
        $chars = 'abdefhknrstyz23456789';
        $length = rand(4, 6);
        $numChars = strlen($chars);
        $str = '';
        for ($i = 0; $i < $length; $i++) {
            $str .= substr($chars, rand(1, $numChars) - 1, 1);
        }
        return $str;
    }
1038166
protected function readFile()
    {
        $file = $this->getFile();
        $raw = $this->ioHelper->getFileContents($file);
        return $this->jsonHelper->decode($raw);
    }