Browse Source

Delete QueryResponseWrapper.php

Cerys Lewis 5 months ago
parent
commit
a62ed0667e
  1. 60
      src/DataStructures/QueryResponseWrapper.php

60
src/DataStructures/QueryResponseWrapper.php

@ -1,60 +0,0 @@
<?php
namespace Darksparrow\DeegraphInteractions\DataStructures;
class QueryResponseWrapper
{
public array $Nodes;
public array $Rows;
public string $RowFormat;
public string $RuleID;
public static function FromAPIResponse(string $response): QueryResponseWrapper
{
$response = json_decode($response, true);
echo "\n\n\n";
var_dump($response);
echo "\n\n\n";
$builder = new QueryResponseWrapper();
if(array_key_exists(key: "@rows", array: $response))
{
$builder->Rows = [];
foreach($response["@rows"] as $row)
$builder->Rows[] = QueryResponseRow::FromArray(array: $row);
$builder->RowFormat = $response["@row_format"];
}
if(array_key_exists(key: "@nodes", array: $response))
{
$builder->Nodes = [];
foreach($response["@nodes"] as $row)
$builder->Nodes = $row;
}
if(array_key_exists(key: "@rule_id", array: $response))
{
$builder->RuleID = $response["@rule_id"];
}
return $builder;
}
public function FlattenRows(): array
{
$builder = [];
foreach($this->Rows as $row)
{
foreach($row->Results as $result)
{
$builder[] = $result;
}
}
return $builder;
}
}
Loading…
Cancel
Save