Conditions | 5 |
Paths | 12 |
Total Lines | 34 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 10.3999 |
Changes | 0 |
1 | <?php |
||
22 | 1 | public function render() |
|
23 | { |
||
24 | // Get the current route and see if it matches a content/file |
||
25 | 1 | $path = $this->di->get("request")->getRoute(); |
|
26 | 1 | $file1 = ANAX_INSTALL_PATH . "/content/$path.md"; |
|
27 | 1 | $file2 = ANAX_INSTALL_PATH . "/content/$path/index.md"; |
|
28 | |||
29 | 1 | $file = is_file($file1) ? $file1 : null; |
|
30 | 1 | $file = is_file($file2) ? $file2 : $file; |
|
31 | |||
32 | 1 | if (!$file) { |
|
|
|||
33 | 1 | return; |
|
34 | } |
||
35 | |||
36 | // Check that file is really in the right place |
||
37 | $real = realpath($file); |
||
38 | $base = realpath(ANAX_INSTALL_PATH . "/content/"); |
||
39 | if (strncmp($base, $real, strlen($base))) { |
||
40 | return; |
||
41 | } |
||
42 | |||
43 | // Get content from markdown file |
||
44 | $content = file_get_contents($file); |
||
45 | $content = $this->di->get("textfilter")->parse( |
||
46 | $content, |
||
47 | ["yamlfrontmatter", "shortcode", "markdown", "titlefromheader"] |
||
48 | ); |
||
49 | |||
50 | // Render a standard page using layout |
||
51 | $this->di->get("view")->add("article/article", [ |
||
52 | "content" => $content->text, |
||
53 | "frontmatter" => $content->frontmatter, |
||
54 | ]); |
||
55 | $this->di->get("pageRender")->renderPage($content->frontmatter); |
||
56 | } |
||
58 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: