public function add(string $id, array $data = []): bool
    {
        try {
            $this->setFile($id);
            if ($this->file) {

                if (!file_exists($this->file)) {
                    //Novo
                    if($this->versionamento) {
                        $data['created'] = strtotime("now");
                        $data['updated'] = strtotime("now");
                        parent::deleteVerion($this->file);
                    }

                    $f = fopen($this->file, "w+");
                    fwrite($f, json_encode($data));
                    fclose($f);

                    return true;
                }
            }
            return false;
        } catch (\Exception $e) {
            return false;
        }
    }
public function add(string $id, array $data = []): bool
    {
        try {
            $this->setFile($id);
            if ($this->file) {

                if (!file_exists($this->file)) {
                    //Novo
                    if($this->versionamento) {
                        $data['created'] = strtotime("now");
                        $data['updated'] = strtotime("now");
                        parent::deleteVerion($this->file);
                    }

                    $f = fopen($this->file, "w+");
                    fwrite($f, json_encode($data));
                    fclose($f);

                    return true;
                }
            }
            return false;
        } catch (\Exception $e) {
            return false;
        }
    }
public function add ( string $ id , array $ data = [ ] ) : bool { try { $ this -> setFile ( $ id ) ; if ( $ this -> file ) { if ( ! file_exists ( $ this -> file ) ) { //Novo if ( $ this -> versionamento ) { $ data [ 'created' ] = strtotime ( "now" ) ; $ data [ 'updated' ] = strtotime ( "now" ) ; parent :: deleteVerion ( $ this -> file ) ; } $ f = fopen ( $ this -> file , "w+" ) ; fwrite ( $ f , json_encode ( $ data ) ) ; fclose ( $ f ) ; return true ; } } return false ; } catch ( \ Exception $ e ) { return false ; } }
Adiciona arquivo Json

@param string $id
@param array $data
@return bool
Adiciona arquivo Json