Passed
Push — master ( ef4849...3d6fe1 )
by Mihail
05:23
created

Sitemap   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A before() 0 5 1
A actionIndex() 0 17 1
1
<?php
2
3
namespace Apps\Controller\Front;
4
5
use Apps\Model\Front\Sitemap\EntityIndexList;
6
use Extend\Core\Arch\FrontAppController;
7
use Ffcms\Core\App;
8
9
/**
10
 * Class Sitemap. Display sitemap for search engines in xml format.
11
 * @package Apps\Controller\Front
12
 */
13
class Sitemap extends FrontAppController
14
{
15
    const EVENT_SITEMAP_LIST = 'sitemap.index';
16
17
    /**
18
     * Before run: set xml header and disable global html layout
19
     */
20
    public function before()
21
    {
22
        $this->layout = null;
23
        App::$Response->headers->set('Content-type', 'text/xml');
24
    }
25
26
    /**
27
     * List available sitemap index links
28
     * @return string
29
     * @throws \Ffcms\Core\Exception\NativeException
30
     * @throws \Ffcms\Core\Exception\SyntaxException
31
     */
32
    public function actionIndex()
33
    {
34
        // initialize model - scan available sitemap indexes
35
        $model = new EntityIndexList(App::$Request->getLanguage());
0 ignored issues
show
Documentation introduced by
\Ffcms\Core\App::$Request->getLanguage() is of type string|null, but the function expects a boolean.

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
        // run event - allow add any other sitemap indexes in model before render it
38
        App::$Event->run(static::EVENT_SITEMAP_LIST, [
39
            'model' => $model
40
        ]);
41
42
        // build information about files
43
        $model->make();
44
45
        return App::$View->render('index', [
46
            'model' => $model
47
        ]);
48
    }
49
}