コード例 #1
0
ファイル: AssetClass.php プロジェクト: junjinZ/wealthbot
 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;
         }
     }
 }
コード例 #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;
 }