IndexController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 37
c 1
b 0
f 0
dl 0
loc 67
ccs 0
cts 37
cp 0
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A omActionGet() 0 14 2
A indexActionGet() 0 42 2
1
<?php
2
3
namespace Aiur18\Question;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
use Aiur18\Question\HTMLForm\CreateForm;
8
use Aiur18\Question\HTMLForm\EditForm;
0 ignored issues
show
Bug introduced by
The type Aiur18\Question\HTMLForm\EditForm was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Aiur18\Question\HTMLForm\DeleteForm;
10
use Aiur18\Question\HTMLForm\UpdateForm;
11
use Aiur18\Question\HTMLForm\CreateAnswer;
12
use Aiur18\Question\HTMLForm\CreateComment;
13
use Aiur18\User\User;
14
use Aiur18\getset\getset;
15
16
/**
17
 * A sample controller to show how a controller class can be implemented.
18
 */
19
class IndexController implements ContainerInjectableInterface
20
{
21
    use ContainerInjectableTrait;
22
23
    /** Method
24
     */
25
    public function indexActionGet() : object
26
    {
27
        $getServer = new getSet();
28
29
        if ($getServer->getServer('user_id') != null) {
30
            $page = $this->di->get("page");
31
            $answer = new Answer();
32
            $answer->setDb($this->di->get("dbqb"));
33
34
            $comment = new Comment();
35
            $comment->setDb($this->di->get("dbqb"));
36
37
            $question = new Question();
38
            $question->setDb($this->di->get("dbqb"));
39
40
            $questionsFindAll = $question->findAll();
41
42
            $questionItemsLast = $question->getLastThree($questionsFindAll);
43
            $questionMostTags = $question->getMostTags($questionsFindAll);
44
            $MostActiveUserId = $question->getMostActive(
45
                $questionsFindAll,
46
                $answer->findAll(),
47
                $comment->findAll()
48
            );
49
50
            $user = new User();
51
            $user->setDb($this->di->get("dbqb"));
52
53
            $MostActiveUser = $user->findAllWhere("id = ?", $MostActiveUserId);
54
55
56
            $page->add("question/crud/view-last", [
57
                "last" => $questionItemsLast,
58
                "tag" => $questionMostTags,
59
                "user" => $MostActiveUser[0],
60
            ]);
61
62
            return $page->render([
63
                "title" => "A collection of items!!!!!!",
64
            ]);
65
        } else {
66
            $this->di->get("response")->redirect("user/login")->send();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return object. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
67
        }
68
    }
69
70
    /** Method
71
     */
72
    public function omActionGet() : object
73
    {
74
        $getServer = new getSet();
75
        if ($getServer->getServer('user_id') != null) {
76
            $page = $this->di->get("page");
77
78
            $page->add("question/crud/om", [
79
            ]);
80
81
            return $page->render([
82
                "title" => "About",
83
            ]);
84
        } else {
85
            $this->di->get("response")->redirect("user/login")->send();
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return object. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
86
        }
87
    }
88
}
89