Passed
Push — master ( d7aea6...81059b )
by Dmitry
02:40
created

I::__callStatic()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
namespace PHPKitchen\CodeSpecs\Actor;
4
5
use PHPKitchen\CodeSpecs\Directive\Wait;
6
use PHPKitchen\CodeSpecs\Expectation\Routing\Router;
7
8
/**
9
 * Spec Actor
10
 *
11
 * @method static void describe(string $scenario)
12
 * @method static void verify(string $scenario, callable $verificationSteps = null)
13
 * @method static void expect(string $scenario, callable $verificationSteps = null)
14
 * @method static Router match(string $variableName)
15
 * @method static Router lookAt(string $variableName)
16
 * @method static Wait wait($numberOfTimeUnits)
17
 * @method static void usePlugin($plugin)
18
 *
19
 * @package PHPKitchen\CodeSpecs\Actor
20
 */
21
class I {
22
    private static $actor = SpecActor::class;
23
24
    public static function __callStatic($name, $arguments) {
25
        $actor = static::getActor();
26
        if (method_exists($actor, $name)) {
27
            return $actor->{$name}(...$arguments);
28
        }
29
        throw new \BadMethodCallException("Method {$name} does not exist at " . self::class);
30
    }
31
32
    private static function getActor(): SpecActor {
33
        if (is_string(self::$actor)) {
0 ignored issues
show
introduced by
The condition is_string(self::actor) is always true.
Loading history...
34
            self::$actor = new self::$actor;
35
        }
36
37
        return self::$actor;
38
    }
39
40
    public static function changeActor($actor) {
41
        self::$actor = $actor;
42
    }
43
}
44