Page   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 32
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIndex() 0 15 2
A replaceVersionPlaceholder() 0 4 1
A getSupportedVersions() 0 8 1
1
<?php
2
3
class Page extends \BaseController {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
  public function getIndex($version, $id = 'installation')
6
  {
7
    $supportedVersions = $this->getSupportedVersions();
8
9
    if(File::exists(base_path()."/docs/$version/$id.md")) {
10
      $page_source = File::get(base_path()."/docs/$version/$id.md");
11
      $pd = new ParsedownExtra();
12
      $page = $this->replaceVersionPlaceholder($version, $pd->text($page_source));
13
      $index = $this->replaceVersionPlaceholder($version, $pd->text(File::get(base_path()."/docs/$version/documentation.md")));
14
    } else {
15
      return Redirect::secure('/');
16
    }
17
18
    return View::make('index', compact('index', 'page', 'version', 'supportedVersions'));
19
  }
20
21
  private function replaceVersionPlaceholder($version, $content)
22
  {
23
    return str_replace('{{version}}', $version, $content);
24
  }
25
26
  private function getSupportedVersions()
27
  {
28
    return [
29
      '5.1' => '5.1',
30
      '5.0' => '5.0',
31
      '4.1' => '4.1'
32
    ];
33
  }
34
}