public function assign(string $key, $value, bool $overwrite = false)
  {
    $file = $this->file;

    if (file_exists($file)) {
      $data = unserialize($this->decrypt(file_get_contents($file)));

      if (is_array($data)) {
        if (isset($data[$key])) {
          if ($overwrite == true) {
            $data[$key] = $value;
            $data = $this->encrypt(serialize($data));
            return file_put_contents($file, $data);
          }
          return false;
        } else {
          $data[$key] = $value;
          $data = $this->encrypt(serialize($data));
          return file_put_contents($file, $data);
        }
      }
    }

    $data = $this->encrypt(serialize([$key => $value]));

    file_put_contents($file, $data);

    return false;
  }
public function assign(string $key, $value, bool $overwrite = false)
  {
    $file = $this->file;

    if (file_exists($file)) {
      $data = unserialize($this->decrypt(file_get_contents($file)));

      if (is_array($data)) {
        if (isset($data[$key])) {
          if ($overwrite == true) {
            $data[$key] = $value;
            $data = $this->encrypt(serialize($data));
            return file_put_contents($file, $data);
          }
          return false;
        } else {
          $data[$key] = $value;
          $data = $this->encrypt(serialize($data));
          return file_put_contents($file, $data);
        }
      }
    }

    $data = $this->encrypt(serialize([$key => $value]));

    file_put_contents($file, $data);

    return false;
  }
public function assign ( string $ key , $ value , bool $ overwrite = false ) { $ file = $ this -> file ; if ( file_exists ( $ file ) ) { $ data = unserialize ( $ this -> decrypt ( file_get_contents ( $ file ) ) ) ; if ( is_array ( $ data ) ) { if ( isset ( $ data [ $ key ] ) ) { if ( $ overwrite == true ) { $ data [ $ key ] = $ value ; $ data = $ this -> encrypt ( serialize ( $ data ) ) ; return file_put_contents ( $ file , $ data ) ; } return false ; } else { $ data [ $ key ] = $ value ; $ data = $ this -> encrypt ( serialize ( $ data ) ) ; return file_put_contents ( $ file , $ data ) ; } } } $ data = $ this -> encrypt ( serialize ( [ $ key => $ value ] ) ) ; file_put_contents ( $ file , $ data ) ; return false ; }
Assign new item to key

@param string $key
@param mixed $value
@param bool $overwrite
@return mixed
Assign new item to key