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

Method readData

lib/Datasource/LocalJson.php:71–93  ·  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

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