Transform payload(s) into an array using custom transformer

@param  mixed $payload
@return array|collection
768421
protected function transformPayload($payload)
    {
        if($payload instanceof Collection) {
            return $this->transformCollectionPayload($payload);
        }

        if($payload instanceof AbstractPaginator) {
            return $this->transformPaginatorPayload($payload);
        }
            
        return $this->transformer->transform($payload);
    }
755278
private function extractJobName($payload)
    {
        $payload = json_decode($payload, true);

        if ($payload && (! isset($payload['data']['command']))) {
            return $payload['job'] ?? null;
        } elseif ($payload && isset($payload['data']['command'])) {
            return $this->matchJobName($payload);
        }
    }
307217
public function parse($payload)
    {
        if (function_exists('msgpack_unpack')) {
            if ($payload) {
                $prevHandler = set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
                    throw new \Exception($errstr);  // @codeCoverageIgnore
                });

                try {
                    $msg = msgpack_unpack(trim($payload));
                    if ( ! $msg) {
                        throw new \Exception('Unknown error');  // @codeCoverageIgnore
                    }
                } catch (\Exception $e) {
                    set_error_handler($prevHandler);
                    throw new ParserException('Failed To Parse MSGPack - ' . $e->getMessage());
                }

                set_error_handler($prevHandler);

                return $msg;
            }
            return [];
        }

        throw new ParserException('Failed To Parse MSGPack - Supporting Library Not Available');  // @codeCoverageIgnore
    }
285111
public static function create(array $payload)
    {
        $text = isset($payload['text']) ? $payload['text'] : null;
        $attachments = isset($payload['attachments']) ? $payload['attachments'] : [];
        $quickReply = isset($payload['quick_reply']) ? $payload['quick_reply']['payload'] : null;

        return new static($payload['mid'], $payload['seq'], $text, $attachments, $quickReply);
    }
812359
public function encode(array $payload)
    {
        // Remove the signature on the builder instance first.
        $this->builder->unsign();

        try {
            foreach ($payload as $key => $value) {
                $this->builder->set($key, $value);
            }
            $this->builder->sign($this->signer, $this->getSigningKey());
        } catch (Exception $e) {
            throw new JWTException('Could not create token: '.$e->getMessage(), $e->getCode(), $e);
        }

        return (string) $this->builder->getToken();
    }
373200
public function transform($map)
    {
        if (is_callable($map)) {
            return $map($this);
        }

        $data = [];
        foreach ($map as $key) {
            $data[$key] = $this->{$key};
        }

        return $data;
    }
814371
public function withPayload($payload): self
    {
        $payload = \is_string($payload) ? $payload : $this->jsonConverter->encode($payload);
        if (false === \mb_detect_encoding($payload, 'UTF-8', true)) {
            throw new \InvalidArgumentException('The payload must be encoded in UTF-8');
        }
        $clone = clone $this;
        $clone->payload = $payload;

        return $clone;
    }
799366
public function parse(string $payload): ResultSpec
    {
        $data = @json_decode($payload, true);

        if (!is_array($data)) {
            throw new BaseClientException('Parse error', JsonRpcException::PARSE_ERROR);
        }

        $units = [];

        if ($this->isSingleResponse($data)) {
            $units[] = $this->decodeResult($data);
            return new ResultSpec($units, true);
        }

        /** @var array $data */
        foreach ($data as $response) {
            $units[] = $this->decodeResult($response);
        }

        return new ResultSpec($units, false);
    }
516846
public function format($payload)
    {
        $payload = $this->fill($payload);
        return "[".$payload['responsecode']."] ".$payload['message']."<br />".$payload['verbosemessage']."<br/>".$payload['url'];

    }
481823
public function encode(array $payload)
    {
        try {
            $this->jws->setPayload($payload)->sign($this->getSigningKey(), $this->getPassphrase());

            return (string) $this->jws->getTokenString();
        } catch (Exception $e) {
            throw new JwTException('Could not create token: '.$e->getMessage(), $e->getCode(), $e);
        }
    }
223336
function parseRequest( $payload )
    {
        if ( isset( $_SERVER['HTTP_SOAPACTION'] ) )
        {
            // this list of replacements built by testing different clients...
            // we should really parse the xml instead!
            $soapaction = trim( $_SERVER['HTTP_SOAPACTION'], '"' );
            $soapaction = preg_replace( array( '#^urn:#', '#^/*#', '#Action$#' ), '', $soapaction );
            $request = new ggPhpSOAPRequest( $soapaction );
            // this call is used to store the raw  xml in the request object
            $request->decodeStream( $payload );
            $request->setSoapVersion( 1 );
            return $request;
        }
        else
        {
            /*$request = new ggPhpSOAPRequest( '...' );
            $request->decodeStream( $payload );
            $request->setSoapVersion( 2 );
            return $request;*/
            return false;
        }
    }
763582
function parseRequest( $payload )
    {
        $request = new ggRESTRequest();
        if ( $request->decodeStream( $payload ) )
        {
            $this->ResponseType = $request->responseType();
            $this->JsonpCallback = $request->jsonpCallback();
            return $request;
        }
        else
        {
            $this->ResponseType = '';
            return false;
        }
    }
1048987
public function encode(Payload $payload)
    {
        $token = $this->provider->encode($payload->get());

        return new Token($token);
    }
1349757
public static function memoize($payload)
    {
        $function = function () use ($payload) {
            static $cache = [];
            $args = func_get_args();
            $hash = md5(serialize($args));

            if (!array_key_exists($hash, $cache)) {
                $cache[$hash] = call_user_func_array($payload, $args);
            }

            return $cache[$hash];
        };

        return $function;
    }
355804
public function parse($payload)
    {
        if ($payload) {
            try {
                $xml = simplexml_load_string($payload, 'SimpleXMLElement', (LIBXML_VERSION >= 20700) ? (LIBXML_PARSEHUGE | LIBXML_NOCDATA) : LIBXML_NOCDATA);
                $ns = ['' => null] + $xml->getDocNamespaces(true);
                return $this->recursive_parse($xml, $ns);
            } catch (\Exception $ex) {
                throw new ParserException('Failed To Parse XML');
            }
        }

        return [];
    }
1245921
public function parse($payload)
    {
        if (function_exists('MongoDB\BSON\toPHP') && ! function_exists('bson_decode')) {
            require_once(__DIR__ . '/BSONPolyfill.php');  //@codeCoverageIgnore
        } elseif ( ! (function_exists('bson_decode') || function_exists('MongoDB\BSON\toPHP'))) {
            throw new ParserException('Failed To Parse BSON - Supporting Library Not Available');  // @codeCoverageIgnore
        }

        if ($payload) {
            $prevHandler = set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
                throw new \Exception($errstr);  // @codeCoverageIgnore
            });

            try {
                $bson = bson_decode(trim($payload, " \t\n\r\x0b"));  // Don't trim \0, as it has valid meaning in BSON
                if ( ! $bson) {
                    throw new \Exception('Unknown error');  // @codeCoverageIgnore
                }
            } catch (\Exception $e) {
                set_error_handler($prevHandler);
                throw new ParserException('Failed To Parse BSON - ' . $e->getMessage());
            }

            set_error_handler($prevHandler);

            return $bson;
        }

        return [];
    }
475368
public static function create(array $payload): self
    {
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];
        $read = Read::create($payload['read']);

        return new static($senderId, $recipientId, $timestamp, $read);
    }