public function save(Persistable $persistable) : void
    {
        if ($this->history and is_file($this->path)) {
            $filename = $this->path . '.' . (string) time() . self::HISTORY_EXT;

            if (!rename($this->path, $filename)) {
                throw new RuntimeException('Failed to rename history,'
                 . ' file, check path and permissions.');
            }
        }

        if (is_file($this->path) and !is_writable($this->path)) {
            throw new RuntimeException("File $this->path is not writable.");
        }

        $data = $this->serializer->serialize($persistable);

        if (!file_put_contents($this->path, $data, LOCK_EX)) {
            throw new RuntimeException('Failed to save persistable to'
                . ' filesystem, check path and permissions.');
        }
    }
public function save(Persistable $persistable) : void
    {
        if ($this->history and is_file($this->path)) {
            $filename = $this->path . '.' . (string) time() . self::HISTORY_EXT;

            if (!rename($this->path, $filename)) {
                throw new RuntimeException('Failed to rename history,'
                 . ' file, check path and permissions.');
            }
        }

        if (is_file($this->path) and !is_writable($this->path)) {
            throw new RuntimeException("File $this->path is not writable.");
        }

        $data = $this->serializer->serialize($persistable);

        if (!file_put_contents($this->path, $data, LOCK_EX)) {
            throw new RuntimeException('Failed to save persistable to'
                . ' filesystem, check path and permissions.');
        }
    }
public function save ( Persistable $ persistable ) : void { if ( $ this -> history and is_file ( $ this -> path ) ) { $ filename = $ this -> path . '.' . ( string ) time ( ) . self :: HISTORY_EXT ; if ( ! rename ( $ this -> path , $ filename ) ) { throw new RuntimeException ( 'Failed to rename history,' . ' file, check path and permissions.' ) ; } } if ( is_file ( $ this -> path ) and ! is_writable ( $ this -> path ) ) { throw new RuntimeException ( "File $this->path is not writable." ) ; } $ data = $ this -> serializer -> serialize ( $ persistable ) ; if ( ! file_put_contents ( $ this -> path , $ data , LOCK_EX ) ) { throw new RuntimeException ( 'Failed to save persistable to' . ' filesystem, check path and permissions.' ) ; } }
Save the persitable model.

@param \Rubix\ML\Persistable $persistable
@throws \RuntimeException
Save the persitable model .