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

ArrayPerfBench::castArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
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
/**
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