Slick.php
/**
     * Parses an incoming Slack request body into key-pairs.
     *
     * @param string $body
     * @return array<string, mixed>
     * @throws Exception if body cannot be parsed.
     */
Parses an incoming Slack request body into key-pairs.
@param string $body
@return array
@throws Exception if body cannot be parsed.
Parses an incoming Slack request body into key - pairs . @param string $body @return array @throws Exception if body cannot be parsed .
public static function parseRequestBody(string $body): array
    {
        if (empty($body)) {
            self::err('body', 'Body must not be empty', 400);
        }
        try {
            if ($body[0] === '{') {
                $data = json_decode($body, true, 512, JSON_THROW_ON_ERROR);
            } else {
                parse_str($body, $data);
                if (isset($data['payload'])) {
                    $data = json_decode(urldecode($data['payload']), true, 512, JSON_THROW_ON_ERROR);
                }
            }
        } catch (JsonException $err) {
            self::err('body', 'Invalid JSON while decoding body', 400, $err);
        }
        if (empty($data)) {
            self::err('body', 'Parsed body yielded no data', 400);
        }
        return $data;
    }
public static function parseRequestBody ( string $ body ) : array { if ( empty ( $ body ) ) { self :: err ( 'body' , 'Body must not be empty' , 400 ) ; } try { if ( $ body [ 0 ] === '{' ) { $ data = json_decode ( $ body , true , 512 , JSON_THROW_ON_ERROR ) ; } else { parse_str ( $ body , $ data ) ; if ( isset ( $ data [ 'payload' ] ) ) { $ data = json_decode ( urldecode ( $ data [ 'payload' ] ) , true , 512 , JSON_THROW_ON_ERROR ) ; } } } catch ( JsonException $ err ) { self :: err ( 'body' , 'Invalid JSON while decoding body' , 400 , $ err ) ; } if ( empty ( $ data ) ) { self :: err ( 'body' , 'Parsed body yielded no data' , 400 ) ; } return $ data ; }
Parses an incoming Slack request body into key-pairs.
Parses an incoming Slack request body into key - pairs .