AnswerController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 60
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexActionGet() 0 8 2
A createAction() 0 16 1
1
<?php
2
3
namespace Forum\Answer;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
use Forum\Answer\HTMLForm\CreateForm;
8
use Forum\Forum\HTMLForm\DeleteForm;
9
use Forum\Forum\HTMLForm\UpdateForm;
10
use Forum\Question\Question;
11
12
// use Anax\Route\Exception\ForbiddenException;
13
// use Anax\Route\Exception\NotFoundException;
14
// use Anax\Route\Exception\InternalErrorException;
15
16
/**
17
 * A sample controller to show how a controller class can be implemented.
18
 */
19
class AnswerController implements ContainerInjectableInterface
20
{
21
    use ContainerInjectableTrait;
22
23
24
    /**
25
     * @var $data description
26
     */
27
    //private $data;
28
29
30
    // /**
31
    //  * The initialize method is optional and will always be called before the
32
    //  * target method/action. This is a convienient method where you could
33
    //  * setup internal properties that are commonly used by several methods.
34
    //  *
35
    //  * @return void
36
    //  */
37
    // public function initialize() : void
38
    // {
39
    //     ;
40
    // }
41
42
43
    /**
44
     * Description.
45
     *
46
     * @param datatype $variable Description
0 ignored issues
show
Bug introduced by
There is no parameter named $variable. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
47
     *
48
     * @return object as a response object
49
     * @throws Exception
50
     *
51
     */
52
    public function indexActionGet(): object
53
    {
54
        $user_id = $this->di->get("session")->get("user_id");
55
        var_dump($user_id);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($user_id); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
56
        if (!$user_id) {
57
            $this->di->get("response")->redirect("user/login");
58
        }
59
    }
60
61
    public function createAction(int $questionId): object
62
    {
63
        $page = $this->di->get("page");
64
        $form = new CreateForm($this->di, $questionId);
65
        $question = new Question();
66
        $question->setDb($this->di->get("dbqb"));
67
        $form->check();
68
        $questionText = $question->findById($questionId)->question;
69
        $data = [
70
            "form" => $form->getHTML(),
71
            "question" => $questionText,
72
            "title" => "create answer",
73
        ];
74
        $page->add("forum/create_answer", $data);
75
        return $page->render($data);
76
    }
77
78
}
79