src/Text.php
public function countSubstring($substring, $caseSensitive = true) {
		$this->verifyNotEmpty($substring, '$substring');
		if ($caseSensitive) {
			return mb_substr_count($this->string, $substring, $this->encoding);
		}
		$str = mb_strtoupper($this->string, $this->encoding);
		$substring = mb_strtoupper($substring, $this->encoding);
		return mb_substr_count($str, $substring, $this->encoding);
	}
public function countSubstring($substring, $caseSensitive = true) {
		$this->verifyNotEmpty($substring, '$substring');
		if ($caseSensitive) {
			return mb_substr_count($this->string, $substring, $this->encoding);
		}
		$str = mb_strtoupper($this->string, $this->encoding);
		$substring = mb_strtoupper($substring, $this->encoding);
		return mb_substr_count($str, $substring, $this->encoding);
	}
public function countSubstring ( $ substring , $ caseSensitive = true ) { $ this -> verifyNotEmpty ( $ substring , '$substring' ) ; if ( $ caseSensitive ) { return mb_substr_count ( $ this -> string , $ substring , $ this -> encoding ) ; } $ str = mb_strtoupper ( $ this -> string , $ this -> encoding ) ; $ substring = mb_strtoupper ( $ substring , $ this -> encoding ) ; return mb_substr_count ( $ str , $ substring , $ this -> encoding ) ; }
Count the number of substring occurrences.

@param string|Text $substring The substring to count the occurrencies
@param boolean $caseSensitive Force case-sensitivity
@return int
Count the number of substring occurrences .