Completed
Push — master ( 4783ce...1821eb )
by Dennis
03:38
created

benchWarmParentItemAccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
/**
4
 * (c) Dennis Meckel
5
 *
6
 * For the full copyright and license information,
7
 * please view the LICENSE file that was distributed with this source code.
8
 */
9
10
namespace Rayne\wz2008\Graph\Benchmark\Graph;
11
12
use Rayne\wz2008\Graph\Benchmark\ParentItemAccessCase;
13
use Rayne\wz2008\Graph\Factory\WzClassificationFactory;
14
use Rayne\wz2008\Graph\WzClassificationInterface;
15
use Rayne\wz2008\Graph\WzItemInterface;
16
17
class GraphParentItemAccessBench extends ParentItemAccessCase
18
{
19
    /**
20
     * @var null|WzItemInterface
21
     */
22
    private $child;
23
24
    /**
25
     * @var WzClassificationInterface
26
     */
27
    private $graph;
28
29
    /**
30
     *
31
     */
32
    public function __construct()
33
    {
34
        $this->graph = WzClassificationFactory::build();
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function benchColdParentItemAccess(array $params)
41
    {
42
        $this->assertSame(
43
            $params['parent'],
44
            $this->graph->get($params['child'])->getParent()->getId());
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    public function beforeWarmParentItemAccess(array $params)
51
    {
52
        $this->child = $this->graph->get($params['child']);
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    public function benchWarmParentItemAccess(array $params)
59
    {
60
        $this->assertSame(
61
            $params['parent'],
62
            $this->child->getParent()->getId());
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68
    public function afterWarmParentItemAccess(array $params)
69
    {
70
        $this->child = null;
71
    }
72
}
73