├── banner.png ├── banner-dark.png ├── .gitignore ├── composer.json ├── phpunit.xml ├── src ├── __register.php ├── Cekimleyici.php ├── SonHece.php └── Sozcuk.php ├── LICENSE ├── .github └── workflows │ └── main.yml ├── tests ├── LetterCaseTests.php └── NounCasesTests.php ├── .php-cs-fixer.php ├── readme.md └── .php_cs /banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aozisik/turkce/HEAD/banner.png -------------------------------------------------------------------------------- /banner-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aozisik/turkce/HEAD/banner-dark.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Composer dependencies 2 | /vendor 3 | 4 | # Cache 5 | .php-cs-fixer.cache 6 | .phpunit.result.cache 7 | 8 | composer.lock -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aozisik/php-turkce", 3 | "description": "Turkish language friendly string manipulation functions for PHP.", 4 | "type": "library", 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "Ahmet ÖZIŞIK", 9 | "email": "ahmet@swiftmade.co" 10 | } 11 | ], 12 | "require-dev": { 13 | "phpunit/phpunit": "^9.0" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "Aozisik\\Turkce\\": "src/" 18 | }, 19 | "files": [ 20 | "src/__register.php" 21 | ] 22 | } 23 | } -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | ./tests/ 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/__register.php: -------------------------------------------------------------------------------- 1 | buyuk(); 15 | } 16 | } 17 | 18 | if (! function_exists('tr_strtolower')) { 19 | function tr_strtolower($sozcuk) 20 | { 21 | return (string) (new \Aozisik\Turkce\Sozcuk($sozcuk)) 22 | ->kucuk(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018-2022 Ahmet Özışık 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: run-tests 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | test: 7 | runs-on: ${{ matrix.os }} 8 | strategy: 9 | fail-fast: true 10 | matrix: 11 | os: [ubuntu-latest] 12 | php: [8.0, 7.4] 13 | dependency-version: [prefer-stable] 14 | 15 | name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} 16 | 17 | steps: 18 | - name: Checkout code 19 | uses: actions/checkout@v2 20 | 21 | - name: Setup PHP 22 | uses: shivammathur/setup-php@v2 23 | with: 24 | php-version: ${{ matrix.php }} 25 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick 26 | coverage: none 27 | 28 | - name: Setup Problem Matches 29 | run: | 30 | echo "::add-matcher::${{ runner.tool_cache }}/php.json" 31 | echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" 32 | 33 | - name: Install dependencies 34 | run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction 35 | 36 | - name: Execute tests 37 | run: vendor/bin/phpunit 38 | -------------------------------------------------------------------------------- /tests/LetterCaseTests.php: -------------------------------------------------------------------------------- 1 | assertTrue('ikmal' == utf8_decode(turkce('İkmal')->kucuk()->yap())); 13 | $this->assertEquals('çılgın koşu', turkce('ÇIlgın KoŞu')->kucuk()); 14 | $this->assertEquals('iyelik ekleri', turkce('İyelİk eklerİ')->kucuk()); 15 | $this->assertEquals('ılık rüzgarlar', turkce('ıLIK RÜZGARLAR')->kucuk()); 16 | } 17 | 18 | /** 19 | * @test 20 | */ 21 | public function buyuk_harfe_cevir() 22 | { 23 | $this->assertEquals('IĞDIR\'DA ILIK İLKBAHAR AKŞAMI', turkce('Iğdır\'da Ilık İlkbahar akşamı')->buyuk()); 24 | } 25 | 26 | /** 27 | * @test 28 | */ 29 | public function baslik_gibi_yap() 30 | { 31 | $this->assertEquals('Çılgın Koşu', turkce('ÇILgın koŞu')->baslik()); 32 | $this->assertEquals('İyelik Ekleri', turkce('iYelik eklerİ')->baslik()); 33 | $this->assertEquals('Ilık Rüzgarlar', turkce('ıLIK RÜZGARLAR')->baslik()); 34 | $this->assertEquals('Iğdır\'da Ilık İlkbahar Akşamı', turkce('ığdIr\'da ılIk ilkbAhar Akşamı')->baslik()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.php-cs-fixer.php: -------------------------------------------------------------------------------- 1 | notPath('vendor') 5 | ->in([ 6 | __DIR__ . '/src', 7 | __DIR__ . '/tests', 8 | ]) 9 | ->name('*.php') 10 | ->notName('*.blade.php') 11 | ->ignoreDotFiles(true) 12 | ->ignoreVCS(true); 13 | 14 | $config = new PhpCsFixer\Config(); 15 | 16 | return $config->setRules([ 17 | 18 | '@PSR2' => true, 19 | 'array_syntax' => ['syntax' => 'short'], 20 | 'ordered_imports' => ['sort_algorithm' => 'length'], 21 | 'no_unused_imports' => true, 22 | 'not_operator_with_successor_space' => true, 23 | 'trailing_comma_in_multiline' => true, 24 | 'phpdoc_scalar' => true, 25 | 'unary_operator_spaces' => true, 26 | 'binary_operator_spaces' => true, 27 | 'blank_line_before_statement' => [ 28 | 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], 29 | ], 30 | 'phpdoc_single_line_var_spacing' => true, 31 | 'phpdoc_var_without_name' => true, 32 | 'class_attributes_separation' => [ 33 | 'elements' => [ 34 | 'method' => 'one', 35 | ], 36 | ], 37 | 'method_argument_space' => [ 38 | 'on_multiline' => 'ensure_fully_multiline', 39 | 'keep_multiple_spaces_after_comma' => true, 40 | ], 41 | 'single_trait_insert_per_statement' => true, 42 | ]) 43 | ->setFinder($finder); 44 | -------------------------------------------------------------------------------- /src/Cekimleyici.php: -------------------------------------------------------------------------------- 1 | kosulHafizasi = []; 21 | $this->soz = $soz; 22 | $this->sonHece = new SonHece($soz); 23 | } 24 | 25 | public function kaynastirma($harf) 26 | { 27 | if ($this->sonHece->sonHarfUnlu()) { 28 | $this->kaynastirma = $harf; 29 | } 30 | 31 | return $this; 32 | } 33 | 34 | public function kural($kosullar, $ek) 35 | { 36 | if ($this->ek) { 37 | // İsabetli kural bulundu, başka kontrole gerek yok 38 | return $this; 39 | } 40 | $kosullar = explode(',', $kosullar); 41 | foreach ($kosullar as $kosul) { 42 | if (! $this->kosulUyumu($kosul)) { 43 | // Bir koşul sağlanmadığında bitir. 44 | return $this; 45 | } 46 | } 47 | $this->ek = $ek; 48 | 49 | return $this; 50 | } 51 | 52 | private function kosulUyumu($kosul) 53 | { 54 | if (! isset($this->kosulHafizasi[$kosul])) { 55 | $this->kosulHafizasi[$kosul] = $this->sonHece->$kosul(); 56 | } 57 | 58 | return $this->kosulHafizasi[$kosul]; 59 | } 60 | 61 | public function ozelIsimMi() 62 | { 63 | $sozler = explode(' ', $this->soz); 64 | $sonSoz = $sozler[count($sozler) - 1]; 65 | 66 | $ilkHarf = mb_substr($sonSoz, 0, 1); 67 | // Sözcüğün ilk harfi büyükse, özel isimdir. 68 | return tr_strtoupper($ilkHarf) === $ilkHarf; 69 | } 70 | 71 | public function sonuc() 72 | { 73 | return new Sozcuk(sprintf( 74 | '%s%s%s%s', 75 | $this->soz, 76 | $this->ozelIsimMi() ? '\'' : '', 77 | $this->kaynastirma, 78 | $this->ek 79 | )); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/SonHece.php: -------------------------------------------------------------------------------- 1 | soz = tr_strtolower($this->sonSoz($soz)); 18 | $this->sonHarf = mb_substr($this->soz, -1); 19 | $this->sonUnluHarf = $this->sonUnluHarfiBul(); 20 | } 21 | 22 | private function sonSoz($soz) 23 | { 24 | $sozler = explode(' ', $soz); 25 | 26 | return end($sozler); 27 | } 28 | 29 | private function sonUnluHarfiBul() 30 | { 31 | $regex = '/' . implode('|', $this->unluler) . '/'; 32 | preg_match_all($regex, $this->soz, $matches); 33 | if (! $matches) { 34 | return false; 35 | } 36 | 37 | return end($matches[0]); 38 | } 39 | 40 | public function sonHarfUnlu() 41 | { 42 | return in_array($this->sonHarf, [ 43 | 'a', 'e', 'ı', 'i', 'o', 'ö', 'u', 'ü', 44 | ]); 45 | } 46 | 47 | public function sert() 48 | { 49 | // Fıstıkçı şahap :) 50 | return in_array($this->sonHarf, [ 51 | 'f', 's', 't', 'k', 'ç', 'ş', 'h', 'p', 52 | ]); 53 | } 54 | 55 | public function yumusak() 56 | { 57 | return ! $this->sert(); 58 | } 59 | 60 | public function kalin() 61 | { 62 | $istisnalar = [ 63 | 'emal', 64 | 'ikmal', 65 | 'lal', 66 | 'hal', 67 | ]; 68 | 69 | foreach ($istisnalar as $istisna) { 70 | $bitis = mb_substr($this->soz, -1 * strlen($istisna)); 71 | 72 | if ($bitis === $istisna) { 73 | return false; 74 | } 75 | } 76 | 77 | return in_array($this->sonUnluHarf, [ 78 | 'a', 'ı', 'u', 'o', 79 | ]); 80 | } 81 | 82 | public function ince() 83 | { 84 | return ! $this->kalin(); 85 | } 86 | 87 | public function yuvarlak() 88 | { 89 | return in_array($this->sonUnluHarf, [ 90 | 'o', 'ö', 'u', 'ü', 91 | ]); 92 | } 93 | 94 | public function duz() 95 | { 96 | return ! $this->yuvarlak(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/Sozcuk.php: -------------------------------------------------------------------------------- 1 | soz = (string) $soz; 12 | } 13 | 14 | public function i() 15 | { 16 | return Cekimleyici::yeni($this->soz) 17 | ->kaynastirma('y') 18 | ->kural('duz,ince', 'i') 19 | ->kural('duz,kalin', 'ı') 20 | ->kural('yuvarlak,ince', 'ü') 21 | ->kural('yuvarlak,kalin', 'u') 22 | ->sonuc(); 23 | } 24 | 25 | public function in() 26 | { 27 | return Cekimleyici::yeni($this->soz) 28 | ->kaynastirma('n') 29 | ->kural('duz,ince', 'in') 30 | ->kural('duz,kalin', 'ın') 31 | ->kural('yuvarlak,ince', 'ün') 32 | ->kural('yuvarlak,kalin', 'un') 33 | ->sonuc(); 34 | } 35 | 36 | public function e() 37 | { 38 | return Cekimleyici::yeni($this->soz) 39 | ->kaynastirma('y') 40 | ->kural('ince', 'e') 41 | ->kural('kalin', 'a') 42 | ->sonuc(); 43 | } 44 | 45 | public function a() 46 | { 47 | return $this->e(); 48 | } 49 | 50 | public function de() 51 | { 52 | return Cekimleyici::yeni($this->soz) 53 | ->kural('sert,ince', 'te') 54 | ->kural('sert,kalin', 'ta') 55 | ->kural('yumusak,ince', 'de') 56 | ->kural('yumusak,kalin', 'da') 57 | ->sonuc(); 58 | } 59 | 60 | public function da() 61 | { 62 | return $this->de(); 63 | } 64 | 65 | public function den() 66 | { 67 | return new self(Cekimleyici::yeni($this->soz) 68 | ->kural('sert,ince', 'ten') 69 | ->kural('sert,kalin', 'tan') 70 | ->kural('yumusak,ince', 'den') 71 | ->kural('yumusak,kalin', 'dan') 72 | ->sonuc()); 73 | } 74 | 75 | public function dan() 76 | { 77 | return $this->den(); 78 | } 79 | 80 | public function kucuk() 81 | { 82 | $str = str_replace(['i', 'I'], ['İ', 'ı'], $this->soz); 83 | $str = mb_convert_case($str, MB_CASE_LOWER); 84 | 85 | return new self(str_replace('i̇', 'i', $str)); 86 | } 87 | 88 | public function buyuk() 89 | { 90 | $str = str_replace(['i', 'I'], ['İ', 'ı'], $this->soz); 91 | 92 | return new self(mb_convert_case($str, MB_CASE_UPPER)); 93 | } 94 | 95 | public function baslik() 96 | { 97 | $str = str_replace(['i', 'I'], ['İ', 'ı'], $this->soz); 98 | $str = mb_convert_case($str, MB_CASE_TITLE); 99 | 100 | return new self(str_replace('i̇', 'i', $str)); 101 | } 102 | 103 | public function yap() 104 | { 105 | return $this->soz; 106 | } 107 | 108 | public function __toString() 109 | { 110 | return $this->yap(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | ![](https://github.com/aozisik/turkce/workflows/run-tests/badge.svg) 10 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) 11 | [![Total Downloads](https://img.shields.io/packagist/dt/aozisik/php-turkce.svg?style=flat-square)](https://packagist.org/packages/aozisik/php-turkce) 12 | 13 | ## Ne yapar? 14 | 15 | - PHP'nin `strtoupper` ve `strtolower` fonksiyonları Türkçe ile uyumsuzdur. Bu paket, i ve I harflerini bozmadan büyük ve küçük harfe çevirir. 16 | 17 | - Verilen Türkçe sözcüğü veya özel ismi, istenen eke göre çekimler. (-e, -i, -in, -de, -den) 18 | 19 | ## Kurulum 20 | 21 | ```bash 22 | composer require aozisik/php-turkce 23 | ``` 24 | 25 | ## Kullanım 26 | 27 | ### Basit kullanım: 28 | 29 | Büyük/küçük harfe çevirme metotlarının başına `tr_` ekleyerek kullanın. 30 | 31 | - `strtoupper` -> `tr_strtoupper` 32 | - `strtolower` -> `tr_strtolower` 33 | 34 | ### Alternatif kullanım: 35 | 36 | ```php 37 | // Büyültme 38 | turkce('izmirin ılık ilkbaharları')->buyuk(); // İZMİRİN ILIK İLKBAHARLARI 39 | 40 | // Küçültme 41 | turkce('İZMİRİN ILIK İLKBAHARLARI')->kucuk(); // izmirin ılık ilkbaharları 42 | 43 | // Başlık 44 | turkce('İZMİRİN ILIK İLKBAHARLARI')->baslik(); // İzmirin Ilık İlkbaharları 45 | ``` 46 | 47 | ### İsmin Hallerine Çekimleme 48 | 49 | İsimlerin yanına gelen ekleri koda gömersek "Ahmet'nin" veya "Hikmet'ye" gibi Türkçe'ye uygun olmayan ve hiç doğal gözükmeyen bir sonuç elde ederiz. Onun yerine, bırakın Türkçe paketi ismi uygun haline çeksin. 50 | 51 | ```php 52 | // Çekimleme 53 | turkce('İstanbul')->den(); // "İstanbul'dan" 54 | turkce('Hatice')->i(); // "Hatice'yi" 55 | turkce('Kemal')->in(); // "Kemal'in" 56 | turkce('Kazım')->e(); // "Kazım'a" 57 | turkce('Asu')->de(); // "Asu'da" 58 | 59 | // Hatta bunu diğer özelliklerle de birleştirebilirsiniz: 60 | turkce('güzel İstanbul')->dan()->baslik(); // "Güzel İstanbul'dan" 61 | ``` 62 | 63 | Kullanılabilen ekler: 64 | 65 | - `i` (belirtme) 66 | - `e` (yönelme) 67 | - `de` (bulunma) 68 | - `den` (ayrılma) 69 | - `in` (iyelik) 70 | 71 | #### Özel isim / genel isim ayrımı 72 | 73 | İsmin hallerine çekimlerken, kütüphane son sözcüğün baş harfini özel genel isim ayrımı yapmak için kullanır. Eğer son sözcük büyük harfle başlıyorsa, özel isim olarak kabul edilir. Bu durumda, hal ekinden önce kesme işareti kullanılır. 74 | 75 | Örneğin: 76 | 77 | ```php 78 | turkce('İstanbul')->den(); // "İstanbul'dan" 79 | turkce('bakkal')->den(); // "bakkaldan" 80 | ``` 81 | 82 | ### Sonucu string olarak dönme 83 | 84 | Eğer sonucu `Sozcuk` sınıfı değil, string olarak almak isterseniz aşağıdaki yöntemlerden birini kullanabilirsiniz: 85 | 86 | ```php 87 | turkce('güzel İstanbul')->dan()->baslik()->yap(); // (string) "Güzel İstanbul'dan" 88 | 89 | // veya 90 | (string) turkce('güzel İstanbul')->dan()->baslik(); // (string) "Güzel İstanbul'dan" 91 | ``` 92 | -------------------------------------------------------------------------------- /tests/NounCasesTests.php: -------------------------------------------------------------------------------- 1 | assertEquals($expected, turkce($word)->$suffix()->yap()); 10 | } 11 | 12 | /** 13 | * @test 14 | */ 15 | public function i_hali() 16 | { 17 | $this->assertSuffix('Suat\'ı', 'Suat', 'i'); 18 | 19 | $this->assertSuffix('Asu\'yu', 'Asu', 'i'); 20 | 21 | $this->assertSuffix('Ümmü\'yü', 'Ümmü', 'i'); 22 | $this->assertSuffix('Ahmet\'i', 'Ahmet', 'i'); 23 | $this->assertSuffix('Kemal\'i', 'Kemal', 'i'); 24 | $this->assertSuffix('Orhon\'u', 'Orhon', 'i'); 25 | $this->assertSuffix('Topal\'ı', 'Topal', 'i'); 26 | $this->assertSuffix('Tuğrul\'u', 'Tuğrul', 'i'); 27 | $this->assertSuffix('Şükran\'ı', 'Şükran', 'i'); 28 | $this->assertSuffix('Kamile\'yi', 'Kamile', 'i'); 29 | $this->assertSuffix('Şefika\'yı', 'Şefika', 'i'); 30 | } 31 | 32 | /** 33 | * @test 34 | */ 35 | public function iyelik() 36 | { 37 | $this->assertSuffix('Asu\'nun', 'Asu', 'in'); 38 | $this->assertSuffix('Suat\'ın', 'Suat', 'in'); 39 | $this->assertSuffix('Ümmü\'nün', 'Ümmü', 'in'); 40 | $this->assertSuffix('Ahmet\'in', 'Ahmet', 'in'); 41 | $this->assertSuffix('Kemal\'in', 'Kemal', 'in'); 42 | $this->assertSuffix('Orhon\'un', 'Orhon', 'in'); 43 | $this->assertSuffix('Tuğrul\'un', 'Tuğrul', 'in'); 44 | $this->assertSuffix('Şükran\'ın', 'Şükran', 'in'); 45 | $this->assertSuffix('Kamile\'nin', 'Kamile', 'in'); 46 | $this->assertSuffix('Şefika\'nın', 'Şefika', 'in'); 47 | } 48 | 49 | /** 50 | * @test 51 | */ 52 | public function e_hali() 53 | { 54 | $this->assertSuffix('Asu\'ya', 'Asu', 'e'); 55 | $this->assertSuffix('Suat\'a', 'Suat', 'e'); 56 | $this->assertSuffix('Ümmü\'ye', 'Ümmü', 'e'); 57 | $this->assertSuffix('Ahmet\'e', 'Ahmet', 'e'); 58 | $this->assertSuffix('Kemal\'e', 'Kemal', 'e'); 59 | $this->assertSuffix('Tuğrul\'a', 'Tuğrul', 'e'); 60 | $this->assertSuffix('Şükran\'a', 'Şükran', 'e'); 61 | $this->assertSuffix('Kamile\'ye', 'Kamile', 'e'); 62 | $this->assertSuffix('Şefika\'ya', 'Şefika', 'e'); 63 | } 64 | 65 | /** 66 | * @test 67 | */ 68 | public function de_hali() 69 | { 70 | $this->assertSuffix('Asu\'da', 'Asu', 'de'); 71 | $this->assertSuffix('Suat\'ta', 'Suat', 'de'); 72 | $this->assertSuffix('Ümmü\'de', 'Ümmü', 'de'); 73 | $this->assertSuffix('Ahmet\'te', 'Ahmet', 'de'); 74 | $this->assertSuffix('Kemal\'de', 'Kemal', 'de'); 75 | $this->assertSuffix('Orhon\'da', 'Orhon', 'de'); 76 | $this->assertSuffix('Tuğrul\'da', 'Tuğrul', 'de'); 77 | $this->assertSuffix('Şükran\'da', 'Şükran', 'de'); 78 | $this->assertSuffix('Kamile\'de', 'Kamile', 'de'); 79 | $this->assertSuffix('Şefika\'da', 'Şefika', 'de'); 80 | } 81 | 82 | /** 83 | * @test 84 | */ 85 | public function den_hali() 86 | { 87 | $this->assertSuffix('Asu\'dan', 'Asu', 'den'); 88 | $this->assertSuffix('Suat\'tan', 'Suat', 'den'); 89 | $this->assertSuffix('Ümmü\'den', 'Ümmü', 'den'); 90 | $this->assertSuffix('Ahmet\'ten', 'Ahmet', 'den'); 91 | $this->assertSuffix('Kemal\'den', 'Kemal', 'den'); 92 | $this->assertSuffix('Tuğrul\'dan', 'Tuğrul', 'den'); 93 | $this->assertSuffix('Şükran\'dan', 'Şükran', 'den'); 94 | $this->assertSuffix('Kamile\'den', 'Kamile', 'den'); 95 | $this->assertSuffix('Şefika\'dan', 'Şefika', 'den'); 96 | } 97 | 98 | /** 99 | * @test 100 | */ 101 | public function ozel_genel_ism_ayrimi() 102 | { 103 | $this->assertSuffix('Kemal\'den', 'Kemal', 'den'); 104 | $this->assertSuffix('hammaldan', 'hammal', 'den'); 105 | } 106 | 107 | /** 108 | * @test 109 | */ 110 | public function unlu_yumusamasi() 111 | { 112 | $this->assertSuffix('Kemal\'den', 'Kemal', 'den'); 113 | $this->assertSuffix('İkmal\'den', 'İkmal', 'den'); 114 | $this->assertSuffix('Asal\'dan', 'Asal', 'den'); 115 | } 116 | 117 | /** 118 | * @test 119 | */ 120 | public function den_hali_ve_baslik() 121 | { 122 | $this->assertEquals( 123 | 'Güzel İstanbul\'dan', 124 | turkce('güzel istanbul')->baslik()->den()->yap(), 125 | ); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | ['syntax' => 'short'], 8 | 'binary_operator_spaces' => [ 9 | 'default' => 'single_space', 10 | 'operators' => ['=>' => null], 11 | ], 12 | 'blank_line_after_namespace' => true, 13 | 'blank_line_after_opening_tag' => true, 14 | 'blank_line_before_statement' => [ 15 | 'statements' => ['return'], 16 | ], 17 | 'braces' => true, 18 | 'cast_spaces' => true, 19 | 'class_attributes_separation' => [ 20 | 'elements' => ['method'], 21 | ], 22 | 'class_definition' => true, 23 | 'concat_space' => [ 24 | 'spacing' => 'one', 25 | ], 26 | 'declare_equal_normalize' => true, 27 | 'elseif' => true, 28 | 'encoding' => true, 29 | 'full_opening_tag' => true, 30 | 'fully_qualified_strict_types' => true, // added by Shift 31 | 'function_declaration' => true, 32 | 'function_typehint_space' => true, 33 | 'heredoc_to_nowdoc' => true, 34 | 'include' => true, 35 | 'increment_style' => ['style' => 'post'], 36 | 'indentation_type' => true, 37 | 'linebreak_after_opening_tag' => true, 38 | 'line_ending' => true, 39 | 'lowercase_cast' => true, 40 | 'lowercase_constants' => true, 41 | 'lowercase_keywords' => true, 42 | 'lowercase_static_reference' => true, // added from Symfony 43 | 'magic_method_casing' => true, // added from Symfony 44 | 'magic_constant_casing' => true, 45 | 'method_argument_space' => true, 46 | 'native_function_casing' => true, 47 | 'no_alias_functions' => true, 48 | 'no_extra_blank_lines' => [ 49 | 'tokens' => [ 50 | 'extra', 51 | 'throw', 52 | 'use', 53 | 'use_trait', 54 | ], 55 | ], 56 | 'no_blank_lines_after_class_opening' => true, 57 | 'no_blank_lines_after_phpdoc' => true, 58 | 'no_closing_tag' => true, 59 | 'no_empty_phpdoc' => true, 60 | 'no_empty_statement' => true, 61 | 'no_leading_import_slash' => true, 62 | 'no_leading_namespace_whitespace' => true, 63 | 'no_mixed_echo_print' => [ 64 | 'use' => 'echo', 65 | ], 66 | 'no_multiline_whitespace_around_double_arrow' => true, 67 | 'multiline_whitespace_before_semicolons' => [ 68 | 'strategy' => 'no_multi_line', 69 | ], 70 | 'no_short_bool_cast' => true, 71 | 'no_singleline_whitespace_before_semicolons' => true, 72 | 'no_spaces_after_function_name' => true, 73 | 'no_spaces_around_offset' => true, 74 | 'no_spaces_inside_parenthesis' => true, 75 | 'no_trailing_comma_in_list_call' => true, 76 | 'no_trailing_comma_in_singleline_array' => true, 77 | 'no_trailing_whitespace' => true, 78 | 'no_trailing_whitespace_in_comment' => true, 79 | 'no_unneeded_control_parentheses' => true, 80 | 'no_unreachable_default_argument_value' => true, 81 | 'no_useless_return' => true, 82 | 'no_whitespace_before_comma_in_array' => true, 83 | 'no_whitespace_in_blank_line' => true, 84 | 'normalize_index_brace' => true, 85 | 'not_operator_with_successor_space' => true, 86 | 'object_operator_without_whitespace' => true, 87 | 'ordered_imports' => ['sortAlgorithm' => 'length'], 88 | 'phpdoc_indent' => true, 89 | 'phpdoc_inline_tag' => true, 90 | 'phpdoc_no_access' => true, 91 | 'phpdoc_no_package' => true, 92 | 'phpdoc_no_useless_inheritdoc' => true, 93 | 'phpdoc_scalar' => true, 94 | 'phpdoc_single_line_var_spacing' => true, 95 | 'phpdoc_summary' => true, 96 | 'phpdoc_to_comment' => true, 97 | 'phpdoc_trim' => true, 98 | 'phpdoc_types' => true, 99 | 'phpdoc_var_without_name' => true, 100 | 'psr4' => true, 101 | 'self_accessor' => true, 102 | 'short_scalar_cast' => true, 103 | 'simplified_null_return' => true, 104 | 'single_blank_line_at_eof' => true, 105 | 'single_blank_line_before_namespace' => true, 106 | 'single_class_element_per_statement' => true, 107 | 'single_import_per_statement' => true, 108 | 'single_line_after_imports' => true, 109 | 'single_line_comment_style' => [ 110 | 'comment_types' => ['hash'], 111 | ], 112 | 'single_quote' => true, 113 | 'space_after_semicolon' => true, 114 | 'standardize_not_equals' => true, 115 | 'switch_case_semicolon_to_colon' => true, 116 | 'switch_case_space' => true, 117 | 'ternary_operator_spaces' => true, 118 | 'trailing_comma_in_multiline_array' => true, 119 | 'trim_array_spaces' => true, 120 | 'unary_operator_spaces' => true, 121 | 'visibility_required' => [ 122 | 'elements' => ['method', 'property'], 123 | ], 124 | 'whitespace_after_comma_in_array' => true, 125 | 'no_unused_imports' => true, 126 | ]; 127 | 128 | $finder = Finder::create() 129 | ->notPath('vendor') 130 | ->in(getcwd()) 131 | ->name('*.php') 132 | ->ignoreDotFiles(true) 133 | ->ignoreVCS(true); 134 | 135 | return Config::create() 136 | ->setFinder($finder) 137 | ->setRules($rules) 138 | ->setRiskyAllowed(true) 139 | ->setUsingCache(true); 140 | --------------------------------------------------------------------------------