<?php
/* Generated PHP wrapper: traffic -> payload -> core -> payload -> traffic. PHP 5.6+. */

{{WIRE_HELPERS}}

{{PAYLOAD_CODEC}}

{{REQUEST_DECODER}}

{{RESPONSE_ENCODER}}

{{PHP_CORE}}

@error_reporting(0);
@ini_set('display_errors', '0');
$request = null;
$failure = function($value) {
    return ['requestId' => is_array($value) && isset($value['requestId'])
        ? (string)$value['requestId'] : '', 'code' => 500, 'error' => []];
};
try {
    {{HEADER_GUARD}}
    $body = file_get_contents('php://input');
    if ($body === false || $body === '') throw new InvalidArgumentException();
    $request = leo_payload_decode(leo_traffic_decode($body));
    $response = {{CORE_ENTRY}}($request);
} catch (Exception $error) {
    $response = $failure($request);
}

http_response_code({{RESPONSE_CODE}});
{{RESPONSE_HEADERS}}
try { echo leo_traffic_encode(leo_payload_encode($response)); }
catch (Exception $error) { http_response_code(500); }
