Total Complexity | 9 |
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 |
||
23 | */ |
||
24 | protected $tracker; |
||
25 | |||
26 | /** |
||
27 | * EventCollection constructor. |
||
28 | * |
||
29 | * @param string $trackerToken |
||
30 | */ |
||
31 | 13 | public function __construct($trackerToken = null) |
|
35 | 2 | } |
|
36 | 13 | } |
|
37 | |||
38 | |||
39 | /** |
||
40 | * Add new event to collection |
||
41 | * |
||
42 | * @param Closure $event |
||
43 | * @param Closure|null $checker |
||
44 | * |
||
45 | * @return \TelegramBot\Api\Events\EventCollection |
||
46 | */ |
||
47 | 4 | public function add(Closure $event, $checker = null) |
|
48 | { |
||
49 | 4 | $this->events[] = !is_null($checker) ? new Event($event, $checker) |
|
50 | 1 | : new Event($event, function () { |
|
51 | 1 | }); |
|
52 | |||
53 | 4 | return $this; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * @param \TelegramBot\Api\Types\Update |
||
58 | */ |
||
59 | 2 | public function handle(Update $update) |
|
70 | } |
||
71 | 1 | } |
|
75 |