Пример #1
0
 /**
  * 
  *
  * @return string
  */
 public function firstByte()
 {
     if ($this->length() > 0) {
         $bytes = $this->getBytes(MRange::rangeWithLength(1));
         return $bytes[0];
     } else {
         throw new MIndexOutOfBoundsException();
     }
 }
Пример #2
0
 /**
  * 
  *
  * @return MArray
  */
 public function subarrayWithRange(MRange $range)
 {
     return new MArray(array_slice($this->array, $range->location(), $range->length()));
 }
Пример #3
0
 /**
  * 
  *
  * @return MString
  */
 public function substringWithRange(MRange $range)
 {
     if ($range->location() < 0) {
         throw new MIndexOutOfBoundsException($range->location(), 0, $this->length());
     }
     if ($range->location() + $range->length() > $this->length()) {
         throw new MIndexOutOfBoundsException($range->location() + $range->length(), 0, $this->length());
     }
     return new MString(substr($this->stringValue(), $range->location(), $range->length()));
 }
Пример #4
0
 /**
  * @internal
  *
  * @return void
  */
 public static function _init()
 {
     self::$RANGE_NOT_FOUND = MRangeMake(MRange::NOT_FOUND, 0);
 }