-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.PossessvieSuffix.php
42 lines (39 loc) · 1.43 KB
/
class.PossessvieSuffix.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
class PossessvieSuffix
{
/**
* @param $word
* @return string
*/
public static function word($word)
{
$lastLetter = substr(mb_strtolower($word, "UTF-8"), -1); //get last letter
$penultimateLetter = substr(mb_strtolower($word, "UTF-8"), -2, 1); //get penultimate letter
$vowels = "aeıioüuü"; //vowels
if (strrchr($vowels, $lastLetter)) { //last letter check
$letterCheck = $lastLetter;
$possessiveSuffixes = array("nın", "nin", "nun", "nün");
} else { //if there isn't vowels in last letter then check penultimate letter
$letterCheck = $penultimateLetter;
$possessiveSuffixes = array("ın", "in", "un", "ün");
}
switch ($letterCheck) { //according to last letter add possessive suffix to word
case "a": case "ı":
$possessive = $possessiveSuffixes[0];
break;
case "e": case "i":
$possessive = $possessiveSuffixes[1];
break;
case "o": case "u":
$possessive = $possessiveSuffixes[2];
break;
case "ö": case "ü":
$possessive = $possessiveSuffixes[3];
break;
default:
$possessive = "nın";
break;
}
return sprintf("%s'%s", $word, $possessive);
}
}