|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is a part of "Axessors" library. |
|
4
|
|
|
* |
|
5
|
|
|
* @author <[email protected]> |
|
6
|
|
|
* @license GPL |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace NoOne4rever\Axessors; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class RunningSuit. |
|
13
|
|
|
* |
|
14
|
|
|
* Stores running configuration. |
|
15
|
|
|
* |
|
16
|
|
|
* @package NoOne4rever\Axessors |
|
17
|
|
|
*/ |
|
18
|
|
|
abstract class RunningSuit |
|
19
|
|
|
{ |
|
20
|
|
|
public const INPUT_MODE = 4; |
|
21
|
|
|
public const OUTPUT_MODE = 8; |
|
22
|
|
|
|
|
23
|
|
|
/** @var object|null object */ |
|
24
|
|
|
protected $object; |
|
25
|
|
|
/** @var PropertyData property data */ |
|
26
|
|
|
protected $propertyData; |
|
27
|
|
|
/** @var string class */ |
|
28
|
|
|
protected $class; |
|
29
|
|
|
/** @var int running mode */ |
|
30
|
|
|
protected $mode; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct(int $mode, PropertyData $data, string $class, $object = null) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->mode = $mode; |
|
35
|
|
|
$this->propertyData = $data; |
|
36
|
|
|
$this->class = $class; |
|
37
|
|
|
$this->object = $object; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Runs *injected* callback or condition. |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $expr *injected* string |
|
44
|
|
|
* @param mixed $var variable to process |
|
45
|
|
|
* @param bool $mode mode of execution |
|
46
|
|
|
* @return mixed the result of *injected* string execution |
|
47
|
|
|
*/ |
|
48
|
|
|
protected function executeInjectedString(string $expr, $var, bool $mode) |
|
49
|
|
|
{ |
|
50
|
|
|
$handler = str_replace('\\`', '`', substr($expr, 1, strlen($expr) - 2)); |
|
51
|
|
|
if (is_null($this->object)) { |
|
52
|
|
|
return call_user_func("{$this->class}::__axessorsExecute", $handler, $var, $mode); |
|
53
|
|
|
} else { |
|
54
|
|
|
return $this->object->__axessorsExecute($handler, $var, $mode); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
} |