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

Test::event()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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