| Total Complexity | 10 |
| Total Lines | 60 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 6 | ||
| Bugs | 2 | Features | 0 |
| 1 | <?php |
||
| 10 | class EventCollection |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Array of events. |
||
| 14 | * |
||
| 15 | * @var array |
||
| 16 | */ |
||
| 17 | protected $events; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Botan tracker |
||
| 21 | * |
||
| 22 | * @var \TelegramBot\Api\Botan|null |
||
| 23 | */ |
||
| 24 | protected $tracker; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * EventCollection constructor. |
||
| 28 | * |
||
| 29 | * @param string $trackerToken |
||
| 30 | */ |
||
| 31 | 13 | public function __construct($trackerToken = null) |
|
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Add new event to collection |
||
| 42 | * |
||
| 43 | * @param Closure $event |
||
| 44 | * @param Closure|null $checker |
||
| 45 | * |
||
| 46 | * @return \TelegramBot\Api\Events\EventCollection |
||
| 47 | 4 | */ |
|
| 48 | public function add(Closure $event, $checker = null) |
||
| 49 | 4 | { |
|
| 50 | 1 | $this->events[] = !is_null($checker) ? new Event($event, $checker) |
|
| 51 | 1 | : new Event($event, function () {}); |
|
| 52 | |||
| 53 | 4 | return $this; |
|
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return void |
||
| 58 | */ |
||
| 59 | 2 | public function handle(Update $update) |
|
| 70 | } |
||
| 71 | 1 | } |
|
| 75 |