/** * * * @return MRange */ public function rangeOfString(MString $string) { $pos = strpos($this->stringValue(), $string->stringValue()); if ($pos !== false) { return MRangeMake($pos, $string->length()); } else { return MRange::RANGE_NOT_FOUND; } }
/** * * * @return MArray */ public function subarrayToIndex($index) { MAssertTypes('int', $index); return $this->subarrayWithRange(MRangeMake(0, $index)); }
/** * @internal * * @return mixed */ function __call($method, $arguments) { $keyName = S($method); $operation = S(""); if ($keyName->startsWith(S("set"))) { $keyName = $keyName->substringWithRange(MRangeMake(3, 1))->toLower()->stringByAppendingString($keyName->substringFromIndex(4)); $operation = S("set"); } else { if ($keyName->startsWith(S("add"))) { $keyName = $keyName->substringWithRange(MRangeMake(3, 1))->toLower()->stringByAppendingString($keyName->substringFromIndex(4)); $operation = S("add"); } else { if ($keyName->startsWith(S("remove"))) { $keyName = $keyName->substringWithRange(MRangeMake(6, 1))->toLower()->stringByAppendingString($keyName->substringFromIndex(7)); $operation = S("remove"); } } } $attribute = $this->entity()->attributeWithName($keyName); if ($attribute) { if ($operation->equals(S("set"))) { $this->setObjectForAttribute($attribute, $arguments[0]); } else { if ($operation->equals(S("add"))) { $this->addObjectToRelationship($attribute, $arguments[0]); } else { if ($operation->equals(S("remove"))) { $this->removeObjectFromRelationship($attribute, $arguments[0]); } else { return $this->objectForAttribute($attribute); } } } } else { throw new MManagedObjectException($this); // Unknown Exception } }
/** * * * @return MRange */ public static function rangeWithLength($length) { return MRangeMake(0, $length); }