public function loadFromArray(array $data = array()) { foreach ($data as $key => $value) { if ($key === 'subclasses') { $subclasses = new SubclassCollection(); foreach ($value as $subclassData) { $class = 'Model\\WealthbotRebalancer\\Subclass'; $subclass = new $class(); $subclass->loadFromArray($subclassData); $subclasses->add($subclass); } $this->setSubclasses($subclasses); } else { $this->{$key} = $value; } } }
/** * Returns collection of diff elements * * @param SubclassCollection $subclasses * @return SubclassCollection */ public function diff(SubclassCollection $subclasses) { $collection = new SubclassCollection(); foreach ($this->_elements as $element) { if (!$subclasses->contains($element)) { $collection->add($element); } } return $collection; }