Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * Jingga
4 *
5 * PHP Version 8.1
6 *
7 * @package   phpOMS\DataStorage\Database\Schema
8 * @copyright Dennis Eichhorn
9 * @license   OMS License 2.0
10 * @version   1.0.0
11 * @link      https://jingga.app
12 */
13declare(strict_types=1);
14
15namespace phpOMS\Router;
16
17use phpOMS\Account\Account;
18
19/**
20 * Router interface.
21 *
22 * @package phpOMS\Router
23 * @license OMS License 2.0
24 * @link    https://jingga.app
25 * @since   1.0.0
26 */
27interface RouterInterface
28{
29    /**
30     * Add routes from file.
31     *
32     * @param string $path Route file path
33     *
34     * @return bool
35     *
36     * @since 1.0.0
37     */
38    public function importFromFile(string $path) : bool;
39
40    /**
41     * Clear routes
42     *
43     * @return void
44     * @since 1.0.0
45     */
46    public function clear() : void;
47
48    /**
49     * Add route.
50     *
51     * @param string $route       Route regex
52     * @param mixed  $destination Destination e.g. Module:function string or callback
53     * @param int    $verb        Request verb
54     * @param bool   $csrf        Is CSRF token required
55     * @param array  $validation  Validation patterns
56     * @param string $dataPattern Data patterns
57     *
58     * @return void
59     *
60     * @since 1.0.0
61     */
62    public function add(
63        string $route,
64        mixed $destination,
65        int $verb = RouteVerb::GET,
66        bool $csrf = false,
67        array $validation = [],
68        string $dataPattern = ''
69    ) : void;
70
71    /**
72     * Route request.
73     *
74     * @param string  $uri     Route
75     * @param string  $csrf    CSRF token
76     * @param int     $verb    Route verb
77     * @param int     $app     Application name
78     * @param int     $unitId  Organization id
79     * @param Account $account Account
80     * @param array   $data    Data
81     *
82     * @return array
83     *
84     * @since 1.0.0
85     */
86    public function route(
87        string $uri,
88        string $csrf = null,
89        int $verb = RouteVerb::GET,
90        int $app = null,
91        int $unitId = null,
92        Account $account = null,
93        array $data = null
94    ) : array;
95}