1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Imanghafoori\HeyMan; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Arr; |
6
|
|
|
use Imanghafoori\HeyMan\Core\Forget; |
7
|
|
|
use Imanghafoori\HeyMan\Core\Reaction; |
8
|
|
|
use Imanghafoori\HeyMan\Switching\Turn; |
9
|
|
|
use Imanghafoori\HeyMan\Core\Situations; |
10
|
|
|
use Imanghafoori\HeyMan\Core\ConditionsFacade; |
11
|
|
|
|
12
|
|
|
class HeyMan |
13
|
|
|
{ |
14
|
|
|
use Turn; |
15
|
|
|
|
16
|
14 |
|
public function forget() |
17
|
|
|
{ |
18
|
14 |
|
return new Forget(); |
19
|
|
|
} |
20
|
|
|
|
21
|
112 |
|
public function __call($method, $args) |
22
|
|
|
{ |
23
|
112 |
|
resolve('heyman.chain')->startChain(); |
|
|
|
|
24
|
|
|
|
25
|
112 |
|
$this->writeDebugInfo(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 2)[1]); |
26
|
|
|
|
27
|
112 |
|
return Situations::call($method, $args); |
28
|
|
|
} |
29
|
|
|
|
30
|
2 |
|
public function checkPoint(string $pointName) |
31
|
|
|
{ |
32
|
2 |
|
event('heyman_checkpoint_'.$pointName); |
33
|
1 |
|
} |
34
|
|
|
|
35
|
2 |
|
public function aliasCondition(string $currentName, string $newName) |
36
|
|
|
{ |
37
|
2 |
|
resolve(ConditionsFacade::class)->alias($currentName, $newName); |
38
|
2 |
|
} |
39
|
|
|
|
40
|
2 |
|
public function aliasSituation(string $currentName, string $newName) |
41
|
|
|
{ |
42
|
2 |
|
Situations::aliasMethod($currentName, $newName); |
43
|
2 |
|
} |
44
|
|
|
|
45
|
1 |
|
public function aliasReaction(string $currentName, string $newName) |
46
|
|
|
{ |
47
|
1 |
|
resolve(Reaction::class)->alias($currentName, $newName); |
48
|
1 |
|
} |
49
|
|
|
|
50
|
|
|
public function defineReaction($methodName, $callable) |
51
|
|
|
{ |
52
|
|
|
resolve(Reaction::class)->define($methodName, $callable); |
53
|
|
|
} |
54
|
|
|
|
55
|
1 |
|
public function defineCondition(string $name, $callable) |
56
|
|
|
{ |
57
|
1 |
|
resolve(ConditionsFacade::class)->define($name, $callable); |
58
|
1 |
|
} |
59
|
|
|
|
60
|
1 |
|
public function condition(string $name, $callable) |
61
|
|
|
{ |
62
|
1 |
|
$this->defineCondition($name, $callable); |
63
|
1 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param $debugTrace |
67
|
|
|
*/ |
68
|
112 |
|
private function writeDebugInfo($debugTrace) |
69
|
|
|
{ |
70
|
112 |
|
if (config('app.debug') && ! app()->environment('production')) { |
|
|
|
|
71
|
|
|
$info = Arr::only($debugTrace, ['file', 'line', 'args']); |
72
|
|
|
resolve('heyman.chain')->set('debugInfo', $info); |
|
|
|
|
73
|
|
|
} |
74
|
112 |
|
} |
75
|
|
|
} |
76
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.