code: public function write(array $hash, $options = 448)
      {
          $dir = dirname($this->path);
          if (!is_dir($dir)) {
              if (file_exists($dir)) {
                  throw new \UnexpectedValueException(
                      $dir.' exists and is not a directory.'
                  );
              }
              if (!@mkdir($dir, 0777, true)) {
                  throw new \UnexpectedValueException(
                      $dir.' does not exist and could not be created.'
                  );
              }
          }
  
          $retries = 3;
          while ($retries--) {
              try {
                  file_put_contents($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
                  break;
              } catch (\Exception $e) {
                  if ($retries) {
                      usleep(500000);
                      continue;
                  }
  
                  throw $e;
              }
          }
      }
docs: Writes json file.
  
  @param  array                                $hash    writes hash into json file
  @param  int                                  $options json_encode options (defaults to JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)
  @throws \UnexpectedValueException|\Exception