Completed
Push — master ( d21dd2...a23d9a )
by Beñat
8s
created

DefaultController::notFoundAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the WordPress Standard project.
5
 *
6
 * Copyright (c) 2015-2016 LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AppTheme\Controller;
13
14
use Timber\Post;
15
use Timber\Timber;
16
17
/**
18
 * Basic controller that works in the same way of MVC frameworks like Laravel or Symfony.
19
 * It uses Timber that renders views with Twig Template engine inside Wordpress.
20
 *
21
 * @author Gorka Laucirica <[email protected]>
22
 * @author Beñat Espiña <[email protected]>
23
 */
24
final class DefaultController
25
{
26
    /**
27
     * Index action.
28
     *
29
     * @return bool|string
30
     */
31
    public function indexAction()
32
    {
33
        $context = Timber::get_context();
34
35
        return Timber::render('pages/index.twig', $context);
0 ignored issues
show
Documentation introduced by
'pages/index.twig' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36
    }
37
38
    /**
39
     * Not found action.
40
     *
41
     * @return bool|string
42
     */
43
    public function notFoundAction()
44
    {
45
        $context = Timber::get_context();
46
47
        return Timber::render('pages/404.twig', $context);
0 ignored issues
show
Documentation introduced by
'pages/404.twig' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
48
    }
49
50
    /**
51
     * Page action.
52
     *
53
     * @return bool|string
54
     */
55
    public function pageAction()
56
    {
57
        $context = Timber::get_context();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
58
        $context['page'] = new Post();
59
60
        return Timber::render('pages/default.twig', $context);
0 ignored issues
show
Documentation introduced by
'pages/default.twig' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
61
    }
62
63
    /**
64
     * Attachment action.
65
     *
66
     * @return bool|string
67
     */
68
    public function attachmentAction()
69
    {
70
        $context = Timber::get_context();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 21 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
71
        $context['attachment'] = Timber::get_post();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
72
        $context['attachment_image'] = wp_attachment_is_image($context['attachment']->ID);
73
74
        return Timber::render('pages/attachment/show.twig', $context);
0 ignored issues
show
Documentation introduced by
'pages/attachment/show.twig' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
75
    }
76
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
77