| Total Complexity | 7 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class Event |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var \Closure |
||
| 12 | */ |
||
| 13 | protected $checker; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var \Closure |
||
| 17 | */ |
||
| 18 | protected $action; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Event constructor. |
||
| 22 | * |
||
| 23 | * @param \Closure $action |
||
| 24 | * @param \Closure|null $checker |
||
| 25 | */ |
||
| 26 | 11 | public function __construct(\Closure $action, \Closure $checker) |
|
| 27 | { |
||
| 28 | 11 | $this->action = $action; |
|
| 29 | 11 | $this->checker = $checker; |
|
| 30 | 11 | } |
|
| 31 | |||
| 32 | /** |
||
| 33 | * @return \Closure |
||
| 34 | */ |
||
| 35 | 1 | public function getAction() |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @return \Closure|null |
||
| 42 | */ |
||
| 43 | 2 | public function getChecker() |
|
| 44 | { |
||
| 45 | 2 | return $this->checker; |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param \TelegramBot\Api\Types\Update |
||
| 50 | * |
||
| 51 | * @return mixed |
||
| 52 | */ |
||
| 53 | 3 | public function executeChecker(Update $message) |
|
| 54 | { |
||
| 55 | 3 | if (is_callable($this->checker)) { |
|
| 56 | 2 | return call_user_func($this->checker, $message); |
|
| 57 | } |
||
| 58 | |||
| 59 | 1 | return false; |
|
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param \TelegramBot\Api\Types\Update |
||
| 64 | * |
||
| 65 | * @return mixed |
||
| 66 | */ |
||
| 67 | 3 | public function executeAction(Update $message) |
|
| 74 | } |
||
| 75 | } |
||
| 76 |