Completed
Push — feature/middleware ( 9d8017...a81095 )
by Derek Stephen
03:54
created

IndexController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Controller;
4
5
use Bone\Http\Response;
6
use Bone\Mvc\OldController;
7
use Bone\Mvc\View\ViewEngine;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\ServerRequestInterface;
10
use Zend\Diactoros\Response\HtmlResponse;
11
use Zend\Diactoros\Stream;
12
13
/**
14
 * Class IndexController
15
 *
16
 * If you need to create a constructor, edit the package to set up automatically via dependency injection
17
 *
18
 * @package App\Controller
19
 */
20
class IndexController
21
{
22
    private $locale;
23
24
    /** @var ViewEngine $view */
25
    private $view;
26
27
    /**
28
     * DragonController constructor.
29
     */
30
    public function __construct(ViewEngine $view)
31
    {
32
        $this->view = $view;
33
    }
34
35
    public function init()
36
    {
37
        $this->locale = $this->view->locale = $this->getParam('locale', Registry::ahoy()->get('i18n')['default_locale']);
0 ignored issues
show
Bug introduced by
The method getParam() does not seem to exist on object<App\Controller\IndexController>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        $this->getTranslator()->setLocale($this->locale);
0 ignored issues
show
Bug introduced by
The method getTranslator() does not seem to exist on object<App\Controller\IndexController>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
    }
40
41
    /**
42
     * @param ServerRequestInterface $request
43
     * @param array $args
44
     * @return ResponseInterface
45
     */
46
    public function indexAction(ServerRequestInterface $request, array $args) : ResponseInterface
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        $body = $this->view->render('index/index');
49
50
        return new HtmlResponse($body);
51
    }
52
53
    /**
54
     * @param ServerRequestInterface $request
55
     * @param array $args
56
     * @return ResponseInterface
57
     */
58
    public function learnAction(ServerRequestInterface $request, array $args) : ResponseInterface
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60
        $body = $this->view->render('index/learn');
61
62
        return new HtmlResponse($body);
63
    }
64
}
65