-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 61a160e
Showing
5 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Epigra | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "epigra/trstringhelper", | ||
"description": "PHP Türkçe Karakter Destekli String Fonksiyonları (toupper,tolower,ucfirst,ucwords,capitalizefirst) Kütüphanesi", | ||
"keywords": ["türkçe","turkish","string","toupper","tolower","ucfirst","ucwords","capitalizefirst"], | ||
"homepage": "https://github.com/epigra/trstringhelper", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Uğur Aydoğdu", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"Epigra\\": "src/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# PHP Türkçe Karakter Destekli String Fonksiyonları (toupper,tolower,ucfirst,ucwords,capitalizefirst) Kütüphanesi | ||
|
||
|
||
## Kullanım | ||
|
||
|
||
```php | ||
use Epigra\TRStringHelper; | ||
|
||
$x = new TRStringHelper("dEneMe. çĞıŞöİÜ"); | ||
echo $x->toLower()->result(); // toUpper,ucFirst, ucWords, capitalizeFirst | ||
|
||
// veya | ||
|
||
$y = (new TRStringHelper())->withString("dEneMe. çĞıŞöİÜ")->toLower()->capitalizeFirst()->result(); | ||
echo $y; | ||
|
||
``` | ||
|
||
## With Pangram (*) | ||
|
||
```php | ||
$p = (new TRStringHelper())->withPangram()->toUpper()->result(); | ||
echo $p; | ||
``` | ||
|
||
## Random Pangram (*) | ||
```php | ||
$rp = TRStringHelper::pangram(); | ||
echo $rp; | ||
``` | ||
|
||
(*) https://tr.wikipedia.org/wiki/Pangram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
namespace Epigra; | ||
|
||
class TRStringHelper { | ||
|
||
private $string; | ||
|
||
private $harfler = [ | ||
'B' => ['I', 'Ğ', 'Ü', 'Ş', 'İ', 'Ö', 'Ç'], | ||
'k' => ['ı', 'ğ', 'ü', 'ş', 'i', 'ö', 'ç'], | ||
'Bi' => [' I', ' ı', ' İ', ' i'], | ||
'ki' => [' I', ' I', ' İ', ' İ'] | ||
]; | ||
|
||
public static $pangrams = [ | ||
'Cümleten şef garsonun verdiği hafif jöle kıvamında poğaçaya bakıyoruz.', // (32) | ||
'Jöle kıvamında beyaz şarap satan iflah olmaz çocuğu gördüm.', // (21) | ||
'Görevdeyken, fahişeye çubuk sürtüp ajite olmayacağız.', // (17) | ||
'Ve japon fahişe çocuklarımızın üstüne böyle geğirdi.', // (16) | ||
'Fütursuz hacı kaçtığına göre japon şemsiyeleri bedava.', // (18) | ||
'Fütursuz kaçığa göre japon şemsiyeleri bedava, hacı!', // (15) | ||
'Füsun kaçtığına göre yemyeşil japon cihazı bedava.', // (14) | ||
'Cılız ve duygulu japon balığı Fethi, sıçarken ölmüş.', // (14) | ||
'Bakkalı pejmürde gösteriveren fahişe çocuğuyuz.', // (13) | ||
'Çocuğu gramaj bazında ek hayvan itlafı pörsütmüş.', // (13) | ||
'Füsun, öptüğü çocuk bagaja sıkışır diye havlamaz.', // (12) | ||
'Tanrım, dört beş felç vaka, çoğu yüzgece sahip, Joe!', // (11) | ||
'Çoğu şef, garip bej cihazıyla müstakil eve döner.', // (11) | ||
'Hazcı bedevi yağlı ruju götüne sokup felç olmuş.', // (11) | ||
'Fahiş bluz güvencesi yağdırma projesi çöktü.', // (9) | ||
'Vakfın çoğu bu hayasız genci plajda görmüştü.', // (9) | ||
'Hayvancağız tüfekçide bagaj törpüsü olmuş.', // (8) | ||
'Öküz ajan hapse düştü yavrum, ocağı felç gibi.', // (8) | ||
'Bu Ganj öküzü hapis düştü yavrum, ocağı felç.', // (7) | ||
'Saf ve haydut kız çocuğu bin plaj görmüş.' // (4) | ||
]; | ||
|
||
function __construct($input=""){ | ||
if($input) $this->string = $input; | ||
|
||
return $this; | ||
} | ||
|
||
public function toLower(){ | ||
$this->string = $this->settolower($this->string); | ||
return $this; | ||
} | ||
|
||
public function toUpper(){ | ||
$this->string = $this->settoupper($this->string); | ||
return $this; | ||
} | ||
|
||
public function ucFirst(){ | ||
$this->string = $this->setucfirst($this->string); | ||
return $this; | ||
} | ||
|
||
public function ucWords(){ | ||
$this->string = $this->setucworsds($this->string); | ||
return $this; | ||
} | ||
|
||
public function capitalizeFirst($c = array('. ', '.', '? ', '?', '! ', '!', ': ', ':')){ | ||
|
||
foreach ($c as $cc) { | ||
$s = explode($cc, $this->string); | ||
foreach ($s as $k => $ss) { | ||
$s[$k] = $this->setucfirst($ss); | ||
} | ||
$str = implode($cc, $s); | ||
} | ||
|
||
$this->string = $str; | ||
return $this; | ||
|
||
foreach ($c as $cc) { | ||
$s = explode($cc, $this->string); | ||
foreach ($s as $k => $ss) { | ||
$s[$k] = $this->setucfirst($ss); | ||
} | ||
$str = implode($cc, $s); | ||
} | ||
$this->string = $str; | ||
return $this; | ||
} | ||
|
||
private function settolower($str){ | ||
return mb_strtolower(str_replace($this->harfler['B'],$this->harfler['k'],$str) , 'utf-8'); | ||
} | ||
|
||
private function settoupper($str){ | ||
return mb_strtoupper(str_replace($this->harfler['k'],$this->harfler['B'], $str), 'utf-8'); | ||
} | ||
|
||
private function setucfirst($str){ | ||
return mb_strtoupper(str_replace($this->harfler['k'],$this->harfler['B'], mb_substr($str, 0, 1, 'utf-8')), 'utf-8') . mb_substr($str, 1, mb_strlen($str, 'utf-8') - 1, 'utf-8'); | ||
} | ||
|
||
private function setucworsds($str){ | ||
return ltrim(mb_convert_case(str_replace($this->harfler['Bi'],$this->harfler['ki'], ' ' . $str), MB_CASE_TITLE, 'utf-8')); | ||
} | ||
|
||
public function withString($str) | ||
{ | ||
$this->string = $str; | ||
return $this; | ||
} | ||
|
||
public function withPangram(){ | ||
shuffle(static::$pangrams); | ||
$this->string = static::$pangrams[0]; | ||
return $this; | ||
} | ||
|
||
public function result() | ||
{ | ||
return $this->string; | ||
} | ||
|
||
public static function pangram($value='') | ||
{ | ||
shuffle(static::$pangrams); | ||
return static::$pangrams[0]; | ||
} | ||
} |