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
![]() |
|||
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 |