Completed
Push — master ( 75744f...bef1ed )
by Mert S.
02:10
created

functions.php ➔ ucwords_tr()   B

Complexity

Conditions 16
Paths 9

Size

Total Lines 20
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 16
eloc 18
c 2
b 0
f 0
nc 9
nop 1
dl 0
loc 20
rs 7.3159

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
	function find($first, $latest, $text) {
4
		preg_match_all("/" . preg_quote($first, "/") .	"(.*?)". preg_quote($latest, "/")."/i", $text, $m);
5
		return @$m[1];
6
	}
7
	
8
	function strtoupperEN($str) {
9
		$str = str_replace(array('i', 'ı', 'ü', 'ğ', 'ş', 'ö', 'ç', 'I', 'İ', 'Ü', 'Ğ', 'Ş', 'Ö', 'Ç'), array('I', 'I', 'U', 'G', 'S', 'O', 'C', 'I', 'I', 'U', 'G', 'S', 'O', 'C'), $str);
10
		return strtoupper($str);
11
	}
12
	
13
	function strtolowerTR($str) {
14
		$str = str_replace(array('i', 'ı', 'ü', 'ğ', 'ş', 'ö', 'ç', 'I', 'İ', 'Ü', 'Ğ', 'Ş', 'Ö', 'Ç'), array('i', 'ı', 'ü', 'ğ', 'ş', 'ö', 'ç', 'ı', 'i','ü', 'ğ', 'ş', 'ö', 'ç'), $str);
15
		return strtolower($str);
16
	}
17
	
18
	function ucwords_tr($gelen){
19
		$sonuc = '';
20
		$kelimeler = explode(" ", $gelen);
21
		foreach ($kelimeler as $kelime_duz){
22
			$kelime_uzunluk = strlen($kelime_duz);
23
			$ilk_karakter = mb_substr($kelime_duz,0,1,'UTF-8');
24
			if($ilk_karakter == 'Ç' or $ilk_karakter=='ç'){$ilk_karakter = 'Ç';}
25
			elseif ($ilk_karakter=='Ğ' or $ilk_karakter=='ğ') {$ilk_karakter='Ğ';}
26
			elseif($ilk_karakter=='I' or $ilk_karakter=='ı'){$ilk_karakter='I';}
27
			elseif ($ilk_karakter=='İ' or $ilk_karakter=='i'){$ilk_karakter='İ';}
28
			elseif ($ilk_karakter=='Ö' or $ilk_karakter=='ö'){$ilk_karakter='Ö';}
29
			elseif ($ilk_karakter=='Ş' or $ilk_karakter=='ş'){$ilk_karakter='Ş';}
30
			elseif ($ilk_karakter=='Ü' or $ilk_karakter=='ü'){$ilk_karakter='Ü';}
31
			else{$ilk_karakter=strtoupper($ilk_karakter);}
32
			$digerleri=mb_substr($kelime_duz,1,$kelime_uzunluk,'UTF-8');
33
			$sonuc.=$ilk_karakter.kucuk_yap($digerleri).' ';
34
		}
35
		$son=trim(str_replace('  ', ' ', $sonuc));
36
		return $son;
37
	}
38
	
39
	function kucuk_yap($gelen){
40
		$gelen=str_replace('Ç', 'ç', $gelen);
41
		$gelen=str_replace('Ğ', 'ğ', $gelen);
42
		$gelen=str_replace('I', 'ı', $gelen);
43
		$gelen=str_replace('İ', 'i', $gelen);
44
		$gelen=str_replace('Ö', 'ö', $gelen);
45
		$gelen=str_replace('Ş', 'ş', $gelen);
46
		$gelen=str_replace('Ü', 'ü', $gelen);
47
		$gelen=strtolower($gelen);
48
49
		return $gelen;
50
	}
51
	
52
	function hashtag($MultiWord){
53
		$MultiWord = strpos($MultiWord, " ");
54
		if	($MultiWord === false)	{$hashtag = "#";}
55
		else						{$hashtag = "";}
56
		return $hashtag;
57
	}
58
	
59
	function editLocal($localeEx, $fileop, $fileopUp){
60
		for ($y = 0; isset($fileop[$y]); $y++) {
61
			if ($localeEx == $fileopUp[$y]) {
62
				$localeTR = ucwords_tr(strtolowerTR($fileop[$y]));
63
				break;
64
			}
65
		}
66
		if (isset($localeTR)) {return $localeTR;}
67
		else {$localeTR = null; return $localeTR; }
68
	}