Code Duplication    Length = 65-65 lines in 3 locations

tests/Doctrine/Performance/Hydration/SimpleQueryArrayHydrationPerformanceBench.php 1 location

@@ 16-80 (lines=65) @@
13
/**
14
 * @BeforeMethods({"init"})
15
 */
16
final class SimpleQueryArrayHydrationPerformanceBench
17
{
18
    /**
19
     * @var ArrayHydrator
20
     */
21
    private $hydrator;
22
23
    /**
24
     * @var ResultSetMapping
25
     */
26
    private $rsm;
27
28
    /**
29
     * @var HydratorMockStatement
30
     */
31
    private $stmt;
32
33
    public function init()
34
    {
35
        $resultSet = [
36
            [
37
                'u__id'       => '1',
38
                'u__status'   => 'developer',
39
                'u__username' => 'romanb',
40
                'u__name'     => 'Roman',
41
            ],
42
            [
43
                'u__id'       => '1',
44
                'u__status'   => 'developer',
45
                'u__username' => 'romanb',
46
                'u__name'     => 'Roman',
47
            ],
48
            [
49
                'u__id'       => '2',
50
                'u__status'   => 'developer',
51
                'u__username' => 'romanb',
52
                'u__name'     => 'Roman',
53
            ]
54
        ];
55
56
        for ($i = 4; $i < 10000; ++$i) {
57
            $resultSet[] = [
58
                'u__id'       => $i,
59
                'u__status'   => 'developer',
60
                'u__username' => 'jwage',
61
                'u__name'     => 'Jonathan',
62
            ];
63
        }
64
65
        $this->stmt     = new HydratorMockStatement($resultSet);
66
        $this->hydrator = new ArrayHydrator(EntityManagerFactory::getEntityManager([]));
67
        $this->rsm      = new ResultSetMapping;
68
69
        $this->rsm->addEntityResult(CmsUser::class, 'u');
70
        $this->rsm->addFieldResult('u', 'u__id', 'id');
71
        $this->rsm->addFieldResult('u', 'u__status', 'status');
72
        $this->rsm->addFieldResult('u', 'u__username', 'username');
73
        $this->rsm->addFieldResult('u', 'u__name', 'name');
74
    }
75
76
    public function benchHydration()
77
    {
78
        $this->hydrator->hydrateAll($this->stmt, $this->rsm);
79
    }
80
}
81
82

tests/Doctrine/Performance/Hydration/SimpleQueryPartialObjectHydrationPerformanceBench.php 1 location

@@ 16-80 (lines=65) @@
13
/**
14
 * @BeforeMethods({"init"})
15
 */
16
final class SimpleQueryPartialObjectHydrationPerformanceBench
17
{
18
    /**
19
     * @var ObjectHydrator
20
     */
21
    private $hydrator;
22
23
    /**
24
     * @var ResultSetMapping
25
     */
26
    private $rsm;
27
28
    /**
29
     * @var HydratorMockStatement
30
     */
31
    private $stmt;
32
33
    public function init()
34
    {
35
        $resultSet = [
36
            [
37
                'u__id'       => '1',
38
                'u__status'   => 'developer',
39
                'u__username' => 'romanb',
40
                'u__name'     => 'Roman',
41
            ],
42
            [
43
                'u__id'       => '1',
44
                'u__status'   => 'developer',
45
                'u__username' => 'romanb',
46
                'u__name'     => 'Roman',
47
            ],
48
            [
49
                'u__id'       => '2',
50
                'u__status'   => 'developer',
51
                'u__username' => 'romanb',
52
                'u__name'     => 'Roman',
53
            ]
54
        ];
55
56
        for ($i = 4; $i < 10000; ++$i) {
57
            $resultSet[] = [
58
                'u__id'       => $i,
59
                'u__status'   => 'developer',
60
                'u__username' => 'jwage',
61
                'u__name'     => 'Jonathan',
62
            ];
63
        }
64
65
        $this->stmt     = new HydratorMockStatement($resultSet);
66
        $this->hydrator = new ObjectHydrator(EntityManagerFactory::getEntityManager([]));
67
        $this->rsm      = new ResultSetMapping;
68
69
        $this->rsm->addEntityResult(CmsUser::class, 'u');
70
        $this->rsm->addFieldResult('u', 'u__id', 'id');
71
        $this->rsm->addFieldResult('u', 'u__status', 'status');
72
        $this->rsm->addFieldResult('u', 'u__username', 'username');
73
        $this->rsm->addFieldResult('u', 'u__name', 'name');
74
    }
75
76
    public function benchHydration()
77
    {
78
        $this->hydrator->hydrateAll($this->stmt, $this->rsm, [Query::HINT_FORCE_PARTIAL_LOAD => true]);
79
    }
80
}
81
82

tests/Doctrine/Performance/Hydration/SimpleQueryScalarHydrationPerformanceBench.php 1 location

@@ 16-80 (lines=65) @@
13
/**
14
 * @BeforeMethods({"init"})
15
 */
16
final class SimpleQueryScalarHydrationPerformanceBench
17
{
18
    /**
19
     * @var ScalarHydrator
20
     */
21
    private $hydrator;
22
23
    /**
24
     * @var ResultSetMapping
25
     */
26
    private $rsm;
27
28
    /**
29
     * @var HydratorMockStatement
30
     */
31
    private $stmt;
32
33
    public function init()
34
    {
35
        $resultSet = [
36
            [
37
                'u__id'       => '1',
38
                'u__status'   => 'developer',
39
                'u__username' => 'romanb',
40
                'u__name'     => 'Roman',
41
            ],
42
            [
43
                'u__id'       => '1',
44
                'u__status'   => 'developer',
45
                'u__username' => 'romanb',
46
                'u__name'     => 'Roman',
47
            ],
48
            [
49
                'u__id'       => '2',
50
                'u__status'   => 'developer',
51
                'u__username' => 'romanb',
52
                'u__name'     => 'Roman',
53
            ]
54
        ];
55
56
        for ($i = 4; $i < 10000; ++$i) {
57
            $resultSet[] = [
58
                'u__id'       => $i,
59
                'u__status'   => 'developer',
60
                'u__username' => 'jwage',
61
                'u__name'     => 'Jonathan',
62
            ];
63
        }
64
65
        $this->stmt     = new HydratorMockStatement($resultSet);
66
        $this->hydrator = new ScalarHydrator(EntityManagerFactory::getEntityManager([]));
67
        $this->rsm      = new ResultSetMapping;
68
69
        $this->rsm->addEntityResult(CmsUser::class, 'u');
70
        $this->rsm->addFieldResult('u', 'u__id', 'id');
71
        $this->rsm->addFieldResult('u', 'u__status', 'status');
72
        $this->rsm->addFieldResult('u', 'u__username', 'username');
73
        $this->rsm->addFieldResult('u', 'u__name', 'name');
74
    }
75
76
    public function benchHydration()
77
    {
78
        $this->hydrator->hydrateAll($this->stmt, $this->rsm);
79
    }
80
}
81
82