You are here

private function RestProcessor::verifyData in Radioactivity 4.0.x

Same name and namespace in other branches
  1. 8.3 src/RestProcessor.php \Drupal\radioactivity\RestProcessor::verifyData()

Simple verification of the incident data.

Parameters

string $data: Json encoded emission data received in $_POST.

Return value

bool True when $data is a valid object, false if not.

1 call to RestProcessor::verifyData()
RestProcessor::processData in src/RestProcessor.php
Processes incoming radioactivity incident data.

File

src/RestProcessor.php, line 117

Class

RestProcessor
The worker class for the Radioactivity rest endpoint.

Namespace

Drupal\radioactivity

Code

private function verifyData($data) {
  $incidents = json_decode($data, TRUE);
  $keys = [
    'fn',
    'et',
    'id',
    'ti',
    'e',
    'h',
  ];
  foreach ($incidents as $incident) {
    if (count($keys) !== count($incident) || count(array_intersect_key(array_flip($keys), $incident)) !== count($keys)) {
      return FALSE;
    }
  }
  return TRUE;
}