-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #451 from nutgram/4.x_new_group_syntax
- Loading branch information
Showing
12 changed files
with
343 additions
and
130 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace SergiX44\Nutgram\Exception; | ||
|
||
use Exception; | ||
use Throwable; | ||
|
||
class StatusFinalizedException extends Exception | ||
{ | ||
public function __construct( | ||
string $message = 'No further handlers can be registered after finalisation.', | ||
int $code = 0, | ||
?Throwable $previous = null | ||
) { | ||
parent::__construct($message, $code, $previous); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace SergiX44\Nutgram\Handlers; | ||
|
||
use Closure; | ||
use SergiX44\Nutgram\Telegram\Types\Command\BotCommandScope; | ||
|
||
class HandlerGroup | ||
{ | ||
protected array $middlewares = []; | ||
|
||
protected array $scopes = []; | ||
|
||
public function __construct(public Closure $groupCallable) | ||
{ | ||
} | ||
|
||
public function middleware(string|array|callable|object $callable): self | ||
{ | ||
array_unshift($this->middlewares, $callable); | ||
return $this; | ||
} | ||
|
||
public function scope(BotCommandScope|array $scope): self | ||
{ | ||
if (!is_array($scope)) { | ||
$scope = [$scope]; | ||
} | ||
|
||
$this->scopes = array_merge($this->scopes, $scope); | ||
return $this; | ||
} | ||
|
||
public function getMiddlewares(): array | ||
{ | ||
return $this->middlewares; | ||
} | ||
|
||
public function getScopes(): array | ||
{ | ||
return $this->scopes; | ||
} | ||
} |
Oops, something went wrong.