BenchmarkFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromCallable() 0 3 1
A fromClosure() 0 3 1
1
<?php
2
3
/**
4
 * For the full copyright and license information, please view
5
 * the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types=1);
9
10
namespace loophp\nanobench;
11
12
use Closure;
13
14
final class BenchmarkFactory implements BenchmarkFactoryInterface
15
{
16
    public function fromCallable(callable $callable, ...$arguments): BenchmarkInterface
17
    {
18
        return $this->fromClosure(Closure::fromCallable($callable), ...$arguments);
19
    }
20
21
    public function fromClosure(Closure $closure, ...$arguments): BenchmarkInterface
22
    {
23
        return new Benchmark((new StopwatchFactory())->new(), $closure, ...$arguments);
24
    }
25
}
26