public function serialize(UserState $state)
    {
        $saveFile = sprintf('%s/%s', $this->path, static::SAVE_FILE);

        $data = file_exists($saveFile)
            ? $this->readJson($saveFile)
            : [];

        $data[$this->workshopName] = [
            'completed_exercises'   => $state->getCompletedExercises(),
            'current_exercise'      => $state->getCurrentExercise(),
        ];

        return file_put_contents($saveFile, json_encode($data));
    }
public function serialize(UserState $state)
    {
        $saveFile = sprintf('%s/%s', $this->path, static::SAVE_FILE);

        $data = file_exists($saveFile)
            ? $this->readJson($saveFile)
            : [];

        $data[$this->workshopName] = [
            'completed_exercises'   => $state->getCompletedExercises(),
            'current_exercise'      => $state->getCurrentExercise(),
        ];

        return file_put_contents($saveFile, json_encode($data));
    }
public function serialize ( UserState $ state ) { $ saveFile = sprintf ( '%s/%s' , $ this -> path , static :: SAVE_FILE ) ; $ data = file_exists ( $ saveFile ) ? $ this -> readJson ( $ saveFile ) : [ ] ; $ data [ $ this -> workshopName ] = [ 'completed_exercises' => $ state -> getCompletedExercises ( ) , 'current_exercise' => $ state -> getCurrentExercise ( ) , ] ; return file_put_contents ( $ saveFile , json_encode ( $ data ) ) ; }
Save the students state for this workshop to disk.

@param UserState $state
@return int
Save the students state for this workshop to disk .