-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathRouterInterface.php
68 lines (59 loc) · 1.87 KB
/
RouterInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php declare(strict_types=1);
/**
* The file is part of inhere/console
*
* @author https://github.com/inhere
* @homepage https://github.com/inhere/php-console
* @license https://github.com/inhere/php-console/blob/master/LICENSE
*/
namespace Inhere\Console\Contract;
use Closure;
/**
* Interface RouterInterface
*
* @package Inhere\Console\Contract
*/
interface RouterInterface
{
public const FOUND = 1;
public const NOT_FOUND = 2;
public const TYPE_GROUP = 1;
public const TYPE_SINGLE = 2;
/**
* Register a app group command(by controller)
*
* @param string|class-string $name The controller name
* @param string|ControllerInterface|null $class The controller class
* @param array{aliases: array, desc: string} $config The options config.
*
* @return static
*/
public function addGroup(string $name, ControllerInterface|string|null $class = null, array $config = []): static;
/**
* Register a app independent console command
*
* @param string|class-string $name
* @param string|CommandInterface|null|Closure():void $handler
* @param array{aliases: array, desc: string, options: array, arguments: array} $config The config.
*
* @return static
*/
public function addCommand(string $name, string|Closure|CommandInterface|null $handler = null, array $config = []): static;
/**
* ```php
* return [
* type => 1, // 1 group 2 command
* handler => handler class/object/func ...
* config => [
* desc => '',
* aliases => [],
* ],
* ]
* ```
*
* @param string $name The input command name
*
* @return array{name:string, cmdId: string, config: array, handler: mixed} return route info. If not found, will return empty array.
*/
public function match(string $name): array;
}