Completed
Push — master ( 8e452b...a34111 )
by Park Jong-Hun
02:44
created

Test   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 6
Bugs 0 Features 0
Metric Value
wmc 7
c 6
b 0
f 0
lcom 1
cbo 3
dl 0
loc 56
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A echoTest() 0 4 1
A paramTest() 0 4 1
A dbTest() 0 5 1
A goMain() 0 4 1
A event() 0 4 1
A jsonTest() 0 17 1
1
<?php
2
3
namespace App\Controller;
4
5
use App\Entity\Post;
6
7
use Core\Application;
8
use Doctrine\ORM\EntityManager;
9
10
class Test
11
{
12
    /**
13
     * @var EntityManager
14
     */
15
    private $entityManager;
16
17
    public function __construct()
18
    {
19
        $this->entityManager = Application::getInstance()->getEntityManager();
20
    }
21
22
    public function echoTest()
23
    {
24
        echo 'Hello Test!';
25
    }
26
27
    public function paramTest($name)
28
    {
29
        echo 'Hello ' . $name . '!';
30
    }
31
32
    public function dbTest()
33
    {
34
        $posts = $this->entityManager->getRepository(Post::class)->findAll();
35
        return $posts;
36
    }
37
38
    public function goMain()
39
    {
40
        return 'redirect: ' . Application::getInstance()->url();
41
    }
42
43
    public function event()
44
    {
45
        echo 'Event!';
46
    }
47
48
    public function jsonTest()
49
    {
50
        return [
51
            [
52
                'title' => 'title 1',
53
                'content' => 'content 1'
54
            ],
55
            [
56
                'title' => 'title 2',
57
                'content' => 'content 2'
58
            ],
59
            [
60
                'title' => 'title 3',
61
                'content' => 'content 3'
62
            ]
63
        ];
64
    }
65
}
66