MCPcopy Create free account
hub / github.com/Rello/analytics / readData

Method readData

lib/Datasource/LocalJson.php:72–94  ·  view source on GitHub ↗

* Read the Data * @param $option * @return array available options of the data source */

($option)

Source from the content-addressed store, hash-verified

70 * @return array available options of the data source
71 */
72 public function readData($option): array {
73 $file = $this->rootFolder->getUserFolder($option['user_id'])->get($option['link']);
74 $cache = $this->getCacheMetadata($option, $file->getMTime());
75 if ($cache['notModified'] === true) {
76 return [
77 'header' => [],
78 'dimensions' => [],
79 'data' => [],
80 'rawdata' => null,
81 'error' => 0,
82 'cache' => $cache,
83 ];
84 }
85
86 $rawResult = $file->getContent();
87
88 $return = $this->jsonParser($option, $rawResult);
89 $return['rawdata'] = $rawResult;
90 $return['error'] = 0;
91 $return['cache'] = $cache;
92
93 return $return;
94 }
95
96 private function getCacheMetadata(array $option, int $mtime): array {
97 $currentCacheKey = 'ljson-' . md5($option['link'] . '|' . $mtime);

Callers

nothing calls this directly

Calls 6

getCacheMetadataMethod · 0.95
jsonParserMethod · 0.95
getUserFolderMethod · 0.80
getMTimeMethod · 0.80
getContentMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected