Example #1
0
 /**
  * Decode from format 
  *
  * @method decode
  * @param {String} $datastore context identifier
  * @void
  */
 public static function Decode(Resource $resource)
 {
     // TODO: «non-silly-impl»
     // lazy lib work around
     $data = array();
     $tmpfilename = time() . ".tmp.csv";
     file_put_contents($tmpfilename, $resource->content());
     // setup lexer
     $lexer = new Lexer(new LexerConfig());
     $interpreter = new Interpreter();
     // do nothing
     $interpreter->addObserver(function (array $row) use(&$data) {
         $data[] = $row;
     });
     // process file
     $lexer->parse($tmpfilename, $interpreter);
     // cleanup
     unlink($tmpfilename);
     return $data;
 }
Example #2
0
 /**
  * Decode from format 
  *
  * @method decode
  * @param {String} $datastore context identifier
  * @void
  */
 public static function Decode(Resource $resource)
 {
     return unserialize($resource->content());
 }
Example #3
0
 /**
  * Decode from format 
  *
  * @method decode
  * @param {String} $datastore context identifier
  * @void
  */
 public static function Decode(Resource $resource)
 {
     return MarkdownDecoder::defaultTransform($resource->content());
 }
Example #4
0
 /**
  * Decode from format 
  *
  * @method decode
  * @param {String} $datastore context identifier
  * @void
  */
 public static function Decode(Resource $resource)
 {
     return json_decode($resource->content());
 }
Example #5
0
 /**
  * Persist data static
  * 
  * @method persistToDisk
  * @param {String} filepath
  * @param {String} contents
  * @void
  */
 public static function persistToDisk(Resource $file)
 {
     // update datastore * perf *
     return file_put_contents($file->path(), $file->content());
 }