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

ArrayPerfBench   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A classSetUp() 0 4 1
A isArray() 0 4 1
A castArray() 0 4 1
A getTestConfig() 0 11 2
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
/**
13
 * @BeforeMethods({"classSetUp"})
14
 * @Revs(10000)
15
 * @Iterations(10)
16
 * @Warmup(2)
17
 * @Groups({"perf"})
18
 */
19
class ArrayPerfBench
20
{
21
    /**
22
     * @var array
23
     */
24
    private $config;
25
26
27
    /**
28
     * Setup config and class
29
     */
30
    public function classSetUp(): void
31
    {
32
        $this->config = $this->getTestConfig();
33
    }
34
35
    /**
36
     * @Subject
37
     */
38
    public function isArray(): bool
39
    {
40
        return is_array($this->config);
41
    }
42
43
    /**
44
     * @Subject
45
     */
46
    public function castArray(): bool
47
    {
48
        return (array)$this->config === $this->config;
49
    }
50
51
    /**
52
     * Returns test config
53
     *
54
     * @return array
55
     */
56
    private function getTestConfig(): array
57
    {
58
        // Load the user-defined test configuration file, if it exists; otherwise, load default
59
        if (is_readable('test/TestConfig.php')) {
60
            $testConfig = require 'test/testing.config.php';
61
        } else {
62
            $testConfig = require 'test/testing.config.php.dist';
63
        }
64
65
        return $testConfig;
66
    }
67
}
68