src/API.php
public function run(): array
    {
        try {
            $result = null;
            if ($this->match !== false && is_callable($this->match['target']) === true) {
                if (func_num_args() > 0) {
                    foreach (func_get_args() as $argument) {
                        $this->match['params'][] = $argument;
                    }
                } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) === false) {
                    $this->match['params'][] = $_POST;
                } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($_GET) === false) {
                    $this->match['params'][] = $_GET;
                } elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') {
                    $_PUT = parse_str(file_get_contents("php://input"));
                    if (empty($_PUT) === false) {
                        $this->match['params'][] = $_PUT;
                    }
                } elseif ($_SERVER['REQUEST_METHOD'] == 'PATCH') {
                    $_PATCH = parse_str(file_get_contents("php://input"));
                    if (empty($_PATCH) === false) {
                        $this->match['params'][] = $_PATCH;
                    }
                }
                $result = call_user_func_array($this->match['target'], $this->match['params']);
            } else {
                throw new \InvalidArgumentException("Method not found");
            }
            return $result;
        } catch (\Throwable $e) {
            if ($e instanceof \InvalidArgumentException) {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 400',
                            true,
                            400
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            } elseif ($e instanceof \DomainException) {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 422',
                            true,
                            422
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            } else {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 500',
                            true,
                            500
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            }
        }
    }
public function run(): array
    {
        try {
            $result = null;
            if ($this->match !== false && is_callable($this->match['target']) === true) {
                if (func_num_args() > 0) {
                    foreach (func_get_args() as $argument) {
                        $this->match['params'][] = $argument;
                    }
                } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST) === false) {
                    $this->match['params'][] = $_POST;
                } elseif ($_SERVER['REQUEST_METHOD'] == 'GET' && empty($_GET) === false) {
                    $this->match['params'][] = $_GET;
                } elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') {
                    $_PUT = parse_str(file_get_contents("php://input"));
                    if (empty($_PUT) === false) {
                        $this->match['params'][] = $_PUT;
                    }
                } elseif ($_SERVER['REQUEST_METHOD'] == 'PATCH') {
                    $_PATCH = parse_str(file_get_contents("php://input"));
                    if (empty($_PATCH) === false) {
                        $this->match['params'][] = $_PATCH;
                    }
                }
                $result = call_user_func_array($this->match['target'], $this->match['params']);
            } else {
                throw new \InvalidArgumentException("Method not found");
            }
            return $result;
        } catch (\Throwable $e) {
            if ($e instanceof \InvalidArgumentException) {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 400',
                            true,
                            400
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            } elseif ($e instanceof \DomainException) {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 422',
                            true,
                            422
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            } else {
                return [
                    "headers" => [
                        [
                            'X-PHP-Response-Code: 500',
                            true,
                            500
                        ]
                    ],
                    "response" => $e->getMessage()
                ];
            }
        }
    }
public function run ( ) : array { try { $ result = null ; if ( $ this -> match !== false && is_callable ( $ this -> match [ 'target' ] ) === true ) { if ( func_num_args ( ) > 0 ) { foreach ( func_get_args ( ) as $ argument ) { $ this -> match [ 'params' ] [ ] = $ argument ; } } elseif ( $ _SERVER [ 'REQUEST_METHOD' ] == 'POST' && empty ( $ _POST ) === false ) { $ this -> match [ 'params' ] [ ] = $ _POST ; } elseif ( $ _SERVER [ 'REQUEST_METHOD' ] == 'GET' && empty ( $ _GET ) === false ) { $ this -> match [ 'params' ] [ ] = $ _GET ; } elseif ( $ _SERVER [ 'REQUEST_METHOD' ] == 'PUT' ) { $ _PUT = parse_str ( file_get_contents ( "php://input" ) ) ; if ( empty ( $ _PUT ) === false ) { $ this -> match [ 'params' ] [ ] = $ _PUT ; } } elseif ( $ _SERVER [ 'REQUEST_METHOD' ] == 'PATCH' ) { $ _PATCH = parse_str ( file_get_contents ( "php://input" ) ) ; if ( empty ( $ _PATCH ) === false ) { $ this -> match [ 'params' ] [ ] = $ _PATCH ; } } $ result = call_user_func_array ( $ this -> match [ 'target' ] , $ this -> match [ 'params' ] ) ; } else { throw new \ InvalidArgumentException ( "Method not found" ) ; } return $ result ; } catch ( \ Throwable $ e ) { if ( $ e instanceof \ InvalidArgumentException ) { return [ "headers" => [ [ 'X-PHP-Response-Code: 400' , true , 400 ] ] , "response" => $ e -> getMessage ( ) ] ; } elseif ( $ e instanceof \ DomainException ) { return [ "headers" => [ [ 'X-PHP-Response-Code: 422' , true , 422 ] ] , "response" => $ e -> getMessage ( ) ] ; } else { return [ "headers" => [ [ 'X-PHP-Response-Code: 500' , true , 500 ] ] , "response" => $ e -> getMessage ( ) ] ; } } }
Runs the API function and returns the result

@return  array
Runs the API function and returns the result