/** * * * @return MRange */ public function __construct($location, $length) { MAssertTypes('int', $location, 'int', $length); parent::__construct(); $this->location = $location; $this->length = $length; }
/** * Constructs a new MPersistentStoreRequest instance. This method should be called * by all subclasses of MPersistentStoreRequest * * @see MPersistentStoreRequest::FetchRequestType * @see MPersistentStoreRequest::SaveRequestType * @see MPersistentStoreRequest::FaultRequestType * * @param int $requestType A constant defining the type of the request, possible * values are: * MPersistentStoreRequest::FetchRequestType * MPersistentStoreRequest::SaveRequestType * MPersistentStoreRequest::FaultRequestType * * @param MManagedObjectContext $context The context in which this Persistent Store * Request will be performed * * @return MPersistentStoreRequest The newly created instance of MPersistentStoreRequest */ public function __construct($requestType, MManagedObjectContext $context) { MAssertTypes('int', $requestType); parent::__construct(); $this->requestType = $requestType; $this->context = $context; }
/** * * * @return MErrorViewController */ public function __construct($responseCode, MNumber $errorCode = null, MString $errorName = null, MString $errorDescription = null) { MAssertTypes('int', $responseCode); parent::__construct(); $this->setResponseCode($responseCode); $this->errorView = new MHTMLErrorDocumentView($errorCode, $errorName, $errorDescription); $this->setView($this->errorView); }
/** * This method should be overriden by subclasses of this class to perform * extra initialization as necessary * * This method initializes a new instance of a subclass of MApplicationControllerAttribute * with the specified name, type and required parameters * * @param MString $name The name of this attribute * @param int $type A constant representing the type of this attribute * Possible values are: * StringType * IntegerType * FloatType * BooleanType * DateType * BinaryType * ArrayType * DictionaryType * @param bool $required Wether or not this attribute is required */ public function __construct(MString $name, $type, $required = true) { MAssertTypes('int', $type, 'bool', $required); parent::__construct(); $this->name = $name; $this->type = $type; $this->required = $required; }
/** * * * @return MIndexOutOfBoundsException */ public function __construct($index = 0, $lowerBound = 0, $upperBound = 0, MException $previous = null) { MAssertTypes('int', $index, 'int', $lowerBound, 'int', $upperBound); parent::__construct(Sf("Index [%d] out of bounds [%d -> %d]", $index, $lowerBound, $upperBound), MException::NUMBER_OUT_OF_RANGE_EXCEPTION_CODE, $previous); $this->index = $index; $this->lowerBound = $lowerBound; $this->upperBound = $upperBound; }
/** * * * @return MData */ public function __construct($bytes) { MAssertTypes('string', $bytes); parent::__construct(); if (!is_string($bytes)) { throw new MInvalidDataTypeException(S("string"), S(gettype($bytes))); } $this->bytes = $bytes; }
/** * @internal * * @return int */ private function _rebuffer($length = 1) { MAssertTypes('int', $length); if (!$this->endOfFile()) { if ($buffer->length() < $length) { $data = $this->stream->read(CHUNK_SIZE); $this->buffer->appendBytes($data); } } return $this->buffer->length(); }
/** * * * @return string */ public function consumeBytes($length) { MAssertTypes('int', $length); $bytes = substr($this->bytes, 0, $length); $this->trimBeginning($length); return $bytes; }
/** * * * @return bool */ public static function fileExists($filePath) { MAssertTypes('string', $filePath); $file = new MFile(S($filePath)); return $file->exists(); }
/** * Sets the data type for this property * * This method sets the type of this entity's property. Below is a list of * supported property types you can use * MEntityDescriptionProperty::StringType * MEntityDescriptionProperty::IntegerType * MEntityDescriptionProperty::FloatType * MEntityDescriptionProperty::BooleanType * MEntityDescriptionProperty::DateType * MEntityDescriptionProperty::BinaryType * * @see MEntityDescriptionProperty::StringType * @see MEntityDescriptionProperty::IntegerType * @see MEntityDescriptionProperty::FloatType * @see MEntityDescriptionProperty::BooleanType * @see MEntityDescriptionProperty::DateType * @see MEntityDescriptionProperty::BinaryType * * @param string $type A string defining the property data type * * @return void */ public function setType($type) { MAssertTypes('string', $type); $this->type = $type; }
/** * Fetches an Object from the Persistent Store * * @param MEntityDescription $entity The entity of the Object you wish to fetch * @param int $objectID The object ID of the Object to be fetched * * @return MManagedObject The retreived Managed Object instance */ public function fetchObjectWithObjectID(MEntityDescription $entity, $objectID) { MAssertTypes('MEntityDescription', $entity, 'int', $objectID); $query = Sf("SELECT `objectID` FROM `%s` WHERE `objectID` = ?", $entity->plural()); $statement = $this->connection()->prepare($query->stringValue()); $statement->bindParam(1, $objectID); $statement->execute(); $row = $statement->fetch(PDO::FETCH_ASSOC); if ($row != null) { $object = $this->persistentStoreCoordinator()->managedObjectContext()->newObjectForEntity($entity, (int) $row['objectID']); return $object; } else { return null; } }
/** * * * @return void */ public function dayOfTheWeekString($format = MDate::FullFormat) { MAssertTypes('int', $format); if ($format == MDate::ShortFormat) { return new MString(date('D', $this->timestamp())); } else { return new MString(date('l', $this->timestamp())); } }
/** * * * @return void */ public function setRestricted($restricted) { MAssertTypes('bool', $restricted); $this->restricted = $restricted; }
/** * */ public function skip($count) { MAssertTypes('int', $count); if (!$this->isClosed()) { $newPosition = $this->position() + $count; if ($newPosition >= $this->fileSize()) { $newPosition = $this->fileSize() - 1; } $this->seek($newPosition); } else { throw new MStreamClosedException($this); } }
/** * * * @return MString */ public function substringToIndex($index) { MAssertTypes('int', $index); return $this->substringWithRange(MRangeMake(0, $index + 1)); }
/** * Sets the output type for this entity provider * * This method sets the output type to be used by this entity provider * when outputting data back to clients. Possible values are: * MEntityProviderViewController::OUTPUT_TYPE_XML * MEntityProviderViewController::OUTPUT_TYPE_JSON * * @see MEntityProviderViewController::OUTPUT_TYPE_XML * @see MEntityProviderViewController::OUTPUT_TYPE_JSON * * @param int $type The output type constant that defines the output * type to be used by this entity provider * * @return void */ public function setOutputType($type) { MAssertTypes('int', $type); if ($type == MEntityProviderViewController::OUTPUT_TYPE_XML) { $this->outputType = $type; $this->setContentType(S("text/xml")); } else { if ($type == MEntityProviderViewController::OUTPUT_TYPE_JSON) { $this->outputType = $type; $this->setContentType(S("application/json")); } else { throw new MException(Sf("Output Type %d not supported!", $type)); } } }
/** * * * @return void */ public function setCode($code) { MAssertTypes('int', $code); $this->code = $code; }
/** * Kills the current application and returns $response to the client * * This function responds to the client using an instance of HTTPResponse * specified by $response and kills the execution of the application * imediately after. * * @see MHTTPResponse * * @param MHTTPResponse $response The HTTP response to return to the client * before killing the application * * @return void */ function MDie(MHTTPResponse $response = null, $returnCode = 0) { MAssertTypes('int', $returnCode); MAppDelegate()->willTerminateWithResponse($response, $returnCode); if (!is_null($response)) { MSendResponse($response); } die($returnCode); }
/** * Creates a new Managed Object instance with the class type specified by the entity * * This creates a new instance of an MManagedObject subclass specified in entity, * inserts it into this context and returns it. * * @param MEntityDescription $entity The entity to create a new instance of * @param int $objectID An optional ID to use for the object. This should only * be used when manullay constructing a representation of the object from the * data store. * * @return MManagedObject The new MManagedObject subclass instance */ public function newObjectForEntity(MEntityDescription $entity, $objectID = MManagedObject::UNKNOWN_ID) { MAssertTypes('int', $objectID); return MObject::newInstanceOfClassWithParameters($entity->entityClassName(), A(array($entity, $this, $objectID))); }
/** * Sets the target type of this relationship * * Use this method to set the target type of this relationship. * This can be one of the following possible values: * MEntityDescriptionRelationship::ToOne -> Relationship links to a single object of the target entity * MEntityDescriptionRelationship::ToMany -> Relationship links to a collection of the target entity * * @see MEntityDescriptionRelationship::ToOne * @see MEntityDescriptionRelationship::ToMany * @see MEntityDescriptionRelationship::to() * * @param int $to A constant defining the target type of this relationship * * @return void */ public function setTo($to) { MAssertTypes('int', $to); $this->to = $to; }
/** * Removes an Object from the specified relationship attribute of this Managed Object * * @param MEntityDescriptionRelationship $relationship The relationship you wish to remove * an object from * @param MManagedObject $object The Managed Object to remove from the relationship * @param bool $updateInverseRelationship Weather or not the inverse relationship should also be updated * * @return void */ public function removeObjectFromRelationship(MEntityDescriptionRelationship $relationship, MManagedObject $object, $updateInverseRelationship = true) { MAssertTypes('bool', $updateInverseRelationship); $this->fireFault(); // Remove object from this side of the relationship $arr = $this->removedRelationships->objectForKey($relationship->name()); if (!$arr) { $arr = new MMutableArray(); $this->removedRelationships->setObjectForKey($relationship->name(), $arr); } $arr->addObject($object); // Update the inverse side of the relationship if necessary if ($updateInverseRelationship) { $object->removeObjectFromRelationship($relationship->inverseRelationship(), $this, false); } }
/** * * * @return MArray */ public function sortedArray($order = MArray::ORDER_ASCENDING, $sortFlags = SORT_REGULAR) { MAssertTypes('int', $order); $sortedArray = $this->array; if ($order == MArray::ORDER_ASCENDING) { sort($sortedArray, $sortFlags); } else { rsort($sortedArray, $sortFlags); } return new MArray($sortedArray); }
/** * */ public function write($data) { MAssertTypes('string', $data); if (!$this->isClosed()) { $written = fwrite($this->handle, $data); if ($written !== false) { return $written; } else { throw new MStreamException($this, S("An error occurred while trying to write to the file.")); } } else { throw new MStreamClosedException($this); } }
/** * * * @return void */ public function removeObjectAtIndex($index) { MAssertTypes('int', $index); if (N($index)->isWithinBounds(N($this->lowerBound()), N($this->upperBound()))) { array_splice($this->array, $index, 1); } else { throw new MIndexOutOfBoundsException($index, $this->lowerBound(), $this->upperBound()); } }
/** * @return void */ public function setShouldAppendEmptyLine($shouldAppendEmptyLine) { MAssertTypes('bool', $shouldAppendEmptyLine); $this->shouldAppendEmptyLine = $shouldAppendEmptyLine; }
/** * * * @return bool */ public function writeByte($byte) { MAssertTypes('string', $byte); $written = $this->write(substr($byte, 0, 1)); return $written > 0; }
/** * Sets weather or not this view should fire faults when a managed object is added * to it. * * If fireFaults is set to false (default), only the object's ID is represented in the * resulting collection XML. * If fireFaults is set to true, the object's ID as well as it's data is represented in * the resulting collection XML. * * @param bool $fireFaults Weather or not this view should fire faults when adding managed * objects to it */ public function setFireFaults($fireFaults) { MAssertTypes('bool', $fireFaults); $this->fireFaults = $fireFaults; }