<?php

class WPML_TM_Word_Count_Set_String {

	private $records;

	private $calculator;

	public function __construct( WPML_TM_Word_Count_Records $records, WPML_TM_Word_Calculator $calculator ) {
		$this->records    = $records;
		$this->calculator = $calculator;
	}

	public function process( $string_id ) {
		$string     = $this->records->get_string_value_and_language( $string_id );
		$word_count = $this->calculator->count_words( $string->value, $string->language );
		$this->records->set_string_word_count( $string_id, $word_count );
	}
}
