Exemplo n.º 1
0
 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;
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 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;
 }