예제 #1
0
 public function testUcfirst()
 {
     $str = new MString('ça me plaît');
     $this->assertEquals('Ça me plaît', \strval($str->ucfirst()));
     $this->assertNotEquals('ça me plaît', \strval($str->ucfirst()));
 }
예제 #2
0
파일: MString.php 프로젝트: dazarobbo/cola
 /**
  * Whether this string starts with a given string
  * @link http://stackoverflow.com/a/3282864/570787
  * @param self $str
  * @param MStringComparison $cmp optional comparision option, default is null (case sensitive)
  * @return bool
  */
 public function startsWith(self $str, MStringComparison $cmp = null)
 {
     if ($str->isNullOrEmpty()) {
         throw new \InvalidArgumentException('$str is empty');
     }
     if ($str->count() > $this->count()) {
         throw new \InvalidArgumentException('$str is longer than $this');
     }
     if ($cmp === null || $cmp->getValue() === MStringComparison::CASE_SENSITIVE) {
         return $this->substring(0, $str->count())->_Value === $str->_Value;
     } else {
         return $this->substring(0, $str->count())->toLower()->_Value === $str->toLower()->_Value;
     }
 }