Completed
Push — master ( 939aa5...a3a240 )
by Jake
05:35
created

PagesController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 73
rs 10
wmc 6
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
B generateSEO() 0 35 4
B home() 0 30 1
A page() 0 3 1
1
<?php
2
3
namespace MeestorHok\Blue\Http\Controllers;
4
 
5
use Illuminate\Routing\Controller;
6
use SEO;
7
use Request;
8
9
//use MeestorHok\Blue\Models\Site;
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
10
//use MeestorHok\Blue\Models\Page as Page;
11
12
class PagesController extends Controller
13
{
14
    private function generateSEO ($site, $page) {
15
        SEO::metatags()
16
            ->setTitleDefault($site['title'])
17
            ->setTitleSeparator(' - ')
18
            ->setTitle($page['title'])
19
            ->setDescription($page['description'])
20
            ->setCanonical(Request::url())
21
            ->addMeta('robots', 'index,follow')
22
            ->addMeta('X-UA-Compatible', 'IE=edge', 'http-equiv');
23
        SEO::opengraph()
24
            ->setTitle($site['title'])
25
            ->setDescription($page['description'])
26
            ->setUrl(Request::url())
27
            ->addProperty('locale', 'en_US')
28
            ->addProperty('type', 'website');
29
        SEO::twitter()
30
            ->setSite($site['twitter'])
31
            ->setTitle($site['title'])
32
            ->setDescription($page['description'])
33
            ->setType('summary')
34
            ->setUrl(Request::url());
35
        if ($site['isMobileOptimized']) {
36
            SEO::metatags()
37
                ->addMeta('HandheldFriendly', 'True')
38
                ->addMeta('MobileOptimized', '320')
39
                ->addMeta('viewport', 'width=device-width, initial-scale=1, shrink-to-fit=no');
40
        }
41
        foreach ($page['images']['heroes'] as $image) {
42
            SEO::opengraph()->addImage(asset($image['uri']));
43
            SEO::twitter()->addImage(asset($image['uri']));
44
        }
45
        foreach ($page['keywords'] as $keyword) {
46
            SEO::metatags()->addKeyword($keyword);
47
        }
48
    }
49
    
50
    public function home () {
51
        $site = [
52
            'title' => 'Blue CMS',
53
            'twitter' => '@BlueCMS',
54
            'isMobileOptimized' => true
55
        ];
56
        $page = [
57
            'title' => 'Home',
58
            'description' => 'Welcome to Blue CMS!',
59
            'keywords' => [
60
                'blue',
61
                'cms',
62
                'seo'
63
            ],
64
            'images' => [
65
                'heroes' => [
66
                    [
67
                        'uri' => 'uploads/adfieuenfvef.png'
68
                    ],
69
                    [
70
                        'uri' => 'uploads/wjqriubasdad.png'
71
                    ]
72
                ]
73
            ]
74
        ];
75
        
76
        $this->generateSEO($site, $page);
77
        
78
        return view('Blue::home');
79
    }
80
    
81
    public function page ($page) {
82
        return '<h1>'.$page.'</h1>';
83
    }
84
}