original_string: protected function findOrCreatePoint(CreateMetricPointCommand $command)
      {
          $buffer = Carbon::now()->subMinutes($command->metric->threshold - 1)->startOfMinute();
  
          if ($point = MetricPoint::where('metric_id', '=', $command->metric->id)->where('value', '=', $command->value)->where('created_at', '>=', $buffer)->first()) {
              return $point;
          }
  
          $data = [
              'metric_id' => $command->metric->id,
              'value'     => $command->value,
              'counter'   => 0,
          ];
  
          if ($command->created_at) {
              $data['created_at'] = $this->dates->create('U', $command->created_at)->format('Y-m-d H:i:s');
          }
  
          return MetricPoint::create($data);
      }
code: protected function findOrCreatePoint(CreateMetricPointCommand $command)
      {
          $buffer = Carbon::now()->subMinutes($command->metric->threshold - 1)->startOfMinute();
  
          if ($point = MetricPoint::where('metric_id', '=', $command->metric->id)->where('value', '=', $command->value)->where('created_at', '>=', $buffer)->first()) {
              return $point;
          }
  
          $data = [
              'metric_id' => $command->metric->id,
              'value'     => $command->value,
              'counter'   => 0,
          ];
  
          if ($command->created_at) {
              $data['created_at'] = $this->dates->create('U', $command->created_at)->format('Y-m-d H:i:s');
          }
  
          return MetricPoint::create($data);
      }
code_tokens: protected function findOrCreatePoint ( CreateMetricPointCommand $ command ) { $ buffer = Carbon :: now ( ) -> subMinutes ( $ command -> metric -> threshold - 1 ) -> startOfMinute ( ) ; if ( $ point = MetricPoint :: where ( 'metric_id' , '=' , $ command -> metric -> id ) -> where ( 'value' , '=' , $ command -> value ) -> where ( 'created_at' , '>=' , $ buffer ) -> first ( ) ) { return $ point ; } $ data = [ 'metric_id' => $ command -> metric -> id , 'value' => $ command -> value , 'counter' => 0 , ] ; if ( $ command -> created_at ) { $ data [ 'created_at' ] = $ this -> dates -> create ( 'U' , $ command -> created_at ) -> format ( 'Y-m-d H:i:s' ) ; } return MetricPoint :: create ( $ data ) ; }
docstring: Find or create a metric point.
  
  @param \CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricPointCommand $command
  
  @return \CachetHQ\Cachet\Models\MetricPoint
docstring_tokens: Find or create a metric point .