GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

OnePageExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getOnePageContent() 0 17 4
1
<?php
2
3
namespace Kmedia\Onepage;
4
5
6
use SilverStripe\CMS\Controllers\ModelAsController;
7
use SilverStripe\CMS\Model\SiteTree;
8
use SilverStripe\ORM\DataExtension;
9
use SilverStripe\View\SSViewer;
10
11
class OnePageExtension extends DataExtension
12
{
13
    public function getOnePageContent()
14
    {
15
        $templateNames = SSViewer::get_templates_by_class(
16
            $this->owner->Classname,
17
            '_onepage',
18
            SiteTree::class
19
        )
20
            ?: ['Page_onepage', 'type' => 'Layout'];
21
22
        foreach ($templateNames as $templateName) {
23
            if (!is_array($templateName)) {
24
                $templateNames[] = [$templateName, 'type' => 'Layout'];
25
            }
26
        }
27
28
        $controller = ModelAsController::controller_for($this->owner);
29
        return $controller->renderWith($templateNames);
30
    }
31
}
32