Esempio n. 1
0
 /**
  * Gets, sets or removes meta data
  * set value to null and unset to true to
  * remove a value from the meta file
  *
  * @param mixed $key
  * @param mixed $value
  *
  * @return mixed
  */
 public function meta($key, $value = null, $unset = false)
 {
     if ($this->exists()) {
         $m_file = App::meta()->file(hash('sha256', $this->_path) . '.meta');
         $meta = [];
         if ($m_file->exists()) {
             $meta = json_decode($m_file->read(), true);
         }
         if ($value === null && isset($meta[$key])) {
             return $meta[$key];
         } elseif ($value === null && $unset === true) {
             unset($meta[$key]);
         } else {
             $meta[$key] = $value;
         }
         return $m_file->write(json_encode($meta));
     }
     return false;
 }