--- /dev/null
+<?php
+/**
+ * This object limits other objects. This is mostly being used to prepare
+ * objects to the datatabase connection or else a lot heap would be saved.
+ */
+class ObjectLimits extends BaseFrameworkSystem {
+ /**
+ * Limitation array for storing all attribute names we will use later
+ * only.
+ */
+ private $limitArray = null;
+
+ /**
+ * Private constructor
+ *
+ * @return void
+ */
+ private final function __construct () {
+ // Call parent constructor
+ parent::constructor(__CLASS__);
+
+ // Set part description
+ $this->setPartDescr("Limitierungsobjekt");
+
+ // Create unique ID number
+ $this->createUniqueID();
+
+ // Clean up a little
+ $this->removeNumberFormaters();
+ }
+
+ /**
+ * Create a new ObjectLimits object and (maybe prepare it a little)
+ *
+ * @param $limitationArray The limitation array we "walk" through
+ * @return $limitInstance The instance to an ObjectLimits object
+ */
+ public final static function createObjectLimits (array $limitationArray) {
+ // Is there a limitation array given?
+ if (count($limitationArray) > 0) {
+ // Get instance
+ $limitInstance = new ObjectLimits();
+
+ // Get all limitations and do them
+ foreach ($limitationArray as $limit) {
+ // What shall we limitate?
+ if ($limit instanceof FrameworkInterface) {
+ // Add an object
+ $limitInstance->addObject($limit);
+ } elseif (is_string($limit)) {
+ // Add a string
+ $limitInstance->addString($limit);
+ } else {
+ // Others are not supported (yet)
+ throw new UnsupportedLimitationPartException($limit, self::EXCEPTION_LIMIT_ELEMENT_IS_UNSUPPORTED);
+ }
+ }
+
+ // Return instance
+ return $limitInstance;
+ } else {
+ // No limitation given so we send "null" back
+ return null;
+ }
+ }
+
+ /**
+ * Add an object's name to the limitation list
+ *
+ * @param $object The object's name we shall add to the list
+ * @return void
+ */
+ private final function addObject (FrameworkInterface $object) {
+ // Auto-initialization
+ if (is_null($this->limitArray)) {
+ // Initialize this array
+ $this->limitArray = new FrameworkArrayObject();
+ }
+
+ // Add the object's name to it
+ $this->limitArray->append($object->__toString());
+ }
+
+ /**
+ * Add a string directly to the limitation list
+ *
+ * @param $str The string we want to add directly
+ * @return void
+ */
+ private final function addString ($str) {
+ // Auto-initialization
+ if (is_null($this->limitArray)) {
+ // Initialize this array
+ $this->limitArray = new FrameworkArrayObject();
+ }
+
+ // Add the direct string to ArrayObject
+ $this->limitArray->append($str);
+ }
+
+ /**
+ * Getter for limitArray
+ *
+ * @return $limitArray The object ArrayObject which holds limitations
+ */
+ public final function getLimitArray () {
+ return $this->limitArray;
+ }
+}
+
+// [EOF]
+?>