Completed
Push — master ( 3af5ad...f60e47 )
by Sandro
10s
created

BaseCase::benchOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Sandro Keil (https://sandro-keil.de)
4
 *
5
 * @link      http://github.com/sandrokeil/interop-config for the canonical source repository
6
 * @copyright Copyright (c) 2015-2016 Sandro Keil
7
 * @license   http://github.com/sandrokeil/interop-config/blob/master/LICENSE.md New BSD License
8
 */
9
10
namespace InteropBench\Config;
11
12
use Interop\Config\RequiresConfig;
13
use Interop\Config\RequiresConfigId;
14
15
/**
16
 * @BeforeMethods({"classSetUp"})
17
 * @Revs(10000)
18
 * @Iterations(10)
19
 * @Warmup(2)
20
 */
21
abstract class BaseCase
22
{
23
    /**
24
     * @var array
25
     */
26
    protected $config;
27
28
    /**
29
     * @var RequiresConfig
30
     */
31
    protected $factory;
32
33
    /**
34
     * @var string
35
     */
36
    protected $configId;
37
38
    /**
39
     * Returns benchmark factory class
40
     *
41
     * @return RequiresConfig
42
     */
43
    abstract protected function getFactoryClass(): RequiresConfig;
44
45
    /**
46
     * Setup config and class
47
     */
48
    public function classSetUp(): void
49
    {
50
        $this->config = $this->getTestConfig();
51
        $this->factory = $this->getFactoryClass();
52
        $this->configId = $this->factory instanceof RequiresConfigId ? 'orm_default' : null;
53
    }
54
55
    /**
56
     * Returns test config
57
     *
58
     * @return array
59
     */
60
    private function getTestConfig(): array
61
    {
62
        // Load the user-defined test configuration file, if it exists; otherwise, load default
63
        if (is_readable('test/TestConfig.php')) {
64
            $testConfig = require 'test/testing.config.php';
65
        } else {
66
            $testConfig = require 'test/testing.config.php.dist';
67
        }
68
69
        return $testConfig;
70
    }
71
}
72